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 show the supported features and APIs that can be used to achieve various Excel-related tasks with the GemBox.Spreadsheet component.

System Requirements

GemBox.Spreadsheet requires only .NET, it doesn't have any other dependency.
You can use it on:

  • .NET Framework 3.5 - 4.8
  • .NET Core 3.0
  • Platforms that implement .NET Standard 2.0 or higher.

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 object to a file in the desired format.

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

class Program
{
    static void Main()
    {
        // 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 As 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

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Spreadsheet yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.