Excel Library for C# and VB.NET applications

GemBox.Spreadsheet is a C#/VB.NET library that provides an easy and high-performance way to process Excel files. It enables developers to read, write, convert, and print spreadsheet files (XLSX, XLS, CSV, ODS, HTML, PDF, XPS, and others) from .NET applications without the need for Microsoft Excel on either the developer's or the client's machine.

GemBox.Spreadsheet requires .NET Framework version 3.0 or above. A special build for .NET Framework version 2.0 is also provided.

GemBox.Spreadsheet examples are listed on the right side of the page. Use the list to explore the supported features.

Below the example description, there are run options, which are used to specify the output file format and execute the example using GemBox.Spreadsheet in Professional mode (without any limitations). For more information about GemBox.Spreadsheet modes (Free, Trial, and Professional), see the Evaluation and Licensing help page.

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.


1using GemBox.Spreadsheet;
2
3class Sample
4{
5    [STAThread]
6    static void Main(string[] args)
7    {
8        // If using Professional version, put your serial key below.
9        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
10
11        ExcelFile ef = new ExcelFile();
12        ExcelWorksheet ws = ef.Worksheets.Add("Hello World");
13
14        ws.Cells[0, 0].Value = "English:";
15        ws.Cells[0, 1].Value = "Hello";
16
17        ws.Cells[1, 0].Value = "Russian:";
18        // Using UNICODE string.
19        ws.Cells[1, 1].Value = new string(new char[] { '\u0417', '\u0434', '\u0440', '\u0430', '\u0432', '\u0441', '\u0442', '\u0432', '\u0443', '\u0439', '\u0442', '\u0435' });
20
21        ws.Cells[2, 0].Value = "Chinese:";
22        // Using UNICODE string.
23        ws.Cells[2, 1].Value = new string(new char[] { '\u4f60', '\u597d' });
24
25        ws.Cells[4, 0].Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your PC.";
26        ws.Cells.GetSubrangeAbsolute(4, 0, 4, 7).Merged = true;
27
28        ef.Save("Hello World.xls");
29    }
30}
1Imports GemBox.Spreadsheet
2
3Module Samples
4
5    Sub Main()
6
7        ' If using Professional version, put your serial key below.
8        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
9
10        Dim ef As ExcelFile = New ExcelFile
11        Dim ws As ExcelWorksheet = ef.Worksheets.Add("Hello World")
12
13        ws.Cells(0, 0).Value = "English:"
14        ws.Cells(0, 1).Value = "Hello"
15
16        ws.Cells(1, 0).Value = "Russian:"
17        ' Using UNICODE string.
18        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)})
19
20        ws.Cells(2, 0).Value = "Chinese:"
21        ' Using UNICODE string.
22        ws.Cells(2, 1).Value = New String(New Char() {ChrW(&H4F60), ChrW(&H597D)})
23
24        ws.Cells(4, 0).Value = "In order to see Russian and Chinese characters you need to have appropriate fonts on your PC."
25        ws.Cells.GetSubrangeAbsolute(4, 0, 4, 7).Merged = True
26
27        ef.Save("Hello World.xls")
28
29    End Sub
30
31End Module

Check next sample or find out more about GemBox.Spreadsheet and GemBox Software.