Following example shows how to read or write to Excel Spreadsheet by using only the GemBox.Spreadsheet .NET component.
GemBox.Spreadsheet is a C# / VB.NET component that provides a simple and efficient way to read, write, convert, and print native Microsoft Excel (XLSX, XLS) and other spreadsheet (ODS, CSV) formats and various document formats (HTML, PDF, XPS) from .NET applications without the need for Microsoft Excel on either the developer or client machines.
GemBox.Spreadsheet Free is free of charge, while GemBox.Spreadsheet Professional is a commercial version that is licensed per developer.
For more information, see GemBox.Spreadsheet Features or try our examples.
Example reads Excel file (in XLS format), selects the active worksheet, changes the value of the cell “A1” and writes the new file:
// Load Excel file.
var workbook = ExcelFile.Load("Workbook.xls");
// Select active worksheet.
var worksheet = workbook.Worksheets.ActiveWorksheet;
// Change the value of the cell "A1".
worksheet.Cells["A1"].Value = "Hello world!";
// Save the file in XLS format.
Visual Basic .NET code:
' Load Excel file.
Dim workbook = ExcelFile.Load("Workbook.xls")
' Select active worksheet.
Dim worksheet = workbook.Worksheets.ActiveWorksheet
' Change the value of the cell "A1".
worksheet.Cells("A1").Value = "Hello world!"
' Save the file in XLS format.