Excel Library for C# and VB.NET applications

The fastest way how you can get started with GemBox.Spreadsheet library is by exploring our collection of C# and VB.NET examples. These are live examples that demonstrate various supported Excel features in GemBox.Spreadsheet.

System Requirements

GemBox.Spreadsheet works on .NET Framework 3.5 or higher and platforms that implement .NET Standard 2.0 or higher.

Hello World

The following example creates a simple Excel file using C# and VB.NET code. 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
Excel Library for C# / VB.NET Screenshot

See the full code below, use Run Example to execute.

using GemBox.Spreadsheet;

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

        ExcelFile ef = new ExcelFile();
        ExcelWorksheet ws = ef.Worksheets.Add("Hello World");

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

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

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

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

        ef.Save("Hello World.xlsx");
    }
}
Imports GemBox.Spreadsheet

Module Samples

    Sub Main()

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

        Dim ef As ExcelFile = New ExcelFile
        Dim ws As ExcelWorksheet = ef.Worksheets.Add("Hello World")

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

        ws.Cells(1, 0).Value = "Russian:"
        ' Using UNICODE string.
        ws.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)})

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

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

        ef.Save("Hello World.xlsx")

    End Sub

End Module