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. GemBox.Spreadsheet requires only .NET, it doesn't have any other dependency. 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: Or you can search and add GemBox.Spreadsheet from the NuGet Package Manager. b) Add from a DLL file. You can download a GemBox.Spreadsheet.dll file from this page and add a reference by browsing to it. c) 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). The second step is to add a directive for the GemBox.Spreadsheet namespace. For a C# project, use: 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: 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 System Requirements
You can use it on:Hello World
Install-Package GemBox.Spreadsheet
using GemBox.Spreadsheet;
For a VB.NET project, use: Import GemBox.Spreadsheet
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
To use a Free mode in a VB.NET project, use: SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
ExcelFile
object to a file in the desired format.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