Excel Library for C# and VB.NET applications

The fastest way to get started with the GemBox.Spreadsheet library is by exploring our collection of C# and VB.NET examples. These are live examples that demonstrate the supported features and APIs that can be used to achieve various Excel-related tasks with the GemBox.Spreadsheet component.

System Requirements

GemBox.Spreadsheet works on .NET Framework 3.5 or higher and platforms that implement .NET Standard 2.0 or higher. It doesn't have any other dependency.

Hello World

The first step in using the GemBox.Spreadsheet library is to add a reference to GemBox.Spreadsheet.dll within your C# or VB.NET project. There are three ways to do that.

a) Add from NuGet.

You can add GemBox.Spreadsheet as a package using the following command from the NuGet Package Manager Console:

Install-Package GemBox.Spreadsheet

Or you can search and add GemBox.Spreadsheet from the NuGet Package Manager.

Adding GemBox.Spreadsheet library from NuGet

b) Add from Setup.

You can download the GemBox.Spreadsheet Setup from this page. After installing the setup, you can add a reference to GemBox.Spreadsheet.dll from the Global Assembly Cache (GAC).

Adding GemBox.Spreadsheet library from GAC

c) Add from a DLL file.

You can download a GemBox.Spreadsheet.dll file from this page and add a reference by browsing to it.

Adding GemBox.Spreadsheet library from DLL

The second step is to add a directive for the GemBox.Spreadsheet namespace.
For a C# project, use using GemBox.Spreadsheet;.
For a VB.NET project, use Import GemBox.Spreadsheet.

The third step is to set the license key to use GemBox.Spreadsheet in one of its working modes.
To use a Free mode in a C# project, use: SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");.
To use a Free mode in a VB.NET project, use: SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY").
You can read more about GemBox.Spreadsheet's working modes on the Evaluation and Licensing help page.

The last step is to write your application-specific Excel workbook code, like the following example code, which shows how to create a simple Excel workbook. It shows how to initialize the GemBox.Spreadsheet content model, populate some cells, and then save an ExcelFile instance to a file in the desired format. It also demonstrates support for international characters (Unicode).

Screenshot of simple Excel file created with GemBox.Spreadsheet
Simple Excel file created with GemBox.Spreadsheet
using GemBox.Spreadsheet;

class Program
{
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        var workbook = new ExcelFile();
        var worksheet = workbook.Worksheets.Add("Hello World");

        worksheet.Cells[0, 0].Value = "English:";
        worksheet.Cells[0, 1].Value = "Hello";

        worksheet.Cells[1, 0].Value = "Russian:";
        // Using UNICODE string.
        worksheet.Cells[1, 1].Value = new string(new char[] { '\u0417', '\u0434', '\u0440', '\u0430', '\u0432', '\u0441', '\u0442', '\u0432', '\u0443', '\u0439', '\u0442', '\u0435' });

        worksheet.Cells[2, 0].Value = "Chinese:";
        // Using UNICODE string.
        worksheet.Cells[2, 1].Value = new string(new char[] { '\u4f60', '\u597d' });

        worksheet.Cells[4, 0].Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your PC.";
        worksheet.Cells.GetSubrangeAbsolute(4, 0, 4, 7).Merged = true;

        workbook.Save("Hello World.%OutputFileType%");
    }
}
Imports GemBox.Spreadsheet

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

        Dim workbook = New ExcelFile
        Dim worksheet = workbook.Worksheets.Add("Hello World")

        worksheet.Cells(0, 0).Value = "English:"
        worksheet.Cells(0, 1).Value = "Hello"

        worksheet.Cells(1, 0).Value = "Russian:"
        ' Using UNICODE string.
        worksheet.Cells(1, 1).Value = New String(New Char() {ChrW(&H417), ChrW(&H434), ChrW(&H440), ChrW(&H430), ChrW(&H432), ChrW(&H441), ChrW(&H442), ChrW(&H432), ChrW(&H443), ChrW(&H439), ChrW(&H442), ChrW(&H435)})

        worksheet.Cells(2, 0).Value = "Chinese:"
        ' Using UNICODE string.
        worksheet.Cells(2, 1).Value = New String(New Char() {ChrW(&H4F60), ChrW(&H597D)})

        worksheet.Cells(4, 0).Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your PC."
        worksheet.Cells.GetSubrangeAbsolute(4, 0, 4, 7).Merged = True

        workbook.Save("Hello World.%OutputFileType%")
    End Sub
End Module

Check next example or download examples from GitHub.