GemBox Software - .NET Components for Reading/Writing Excel files and Compound Document files  
Search gemboxsoftware.com:    
    
 
 
 
 
  FAQ
  Bugs & Features
  Articles



How to Read and Write to XLS, XLSX, CSV and HTML files from your .NET applications by using only our .NET Component?

Following example shows how to read or write to XLS, XLSX, CSV and HTML files by using only GemBox.Spreadsheet .NET component.

GemBox.Spreadsheet is a .NET component which provides easy and high performance way to write, read or convert native Microsoft Excel files (XLS, CSV or XLSX) and HTML files without the need for Microsoft Excel on either the developer or client machines. GemBox.Spreadsheet Free comes free of charge while GemBox.Spreadsheet Professional is a commercial version (licensed per developer). Find more information about GemBox.Spreadsheet features or reasons why our component is better then Excel Automation.

Example reads Excel file (in XLS format), changes the value of the cell "A1" and writes the new file:

C# code:

ExcelFile ef = new ExcelFile();

// Loads Excel file.
ef.LoadXls("filename.xls");

// Selects first worksheet.
ExcelWorksheet ws = ef.Worksheets[0];

// Change the value of the cell "A1".
ws.Cells["A1"].Value = "Hello world!";

// Saves the file in XLS format.
ef.SaveXls("NewFile.xls");


Visual Basic .NET code:

Dim ef As New ExcelFile

' Loads Excel file.
ef.LoadXls("filename.xls")

' Selects first worksheet.
Dim ws As ExcelWorksheet = ef.Worksheets(0)

' Change the value of the cell "A1".
ws.Cells("A1").Value = "Hello world!"

' Saves the file in XLS format.
ef.SaveXls("NewFile.xls")


To read/write the file to another format you only need to replace the LoadXls/SaveXls method with preferred one (LoadXlsx/SaveXlsx, LoadCsv/SaveCsv or SaveHtml).

















© GemBox Software. All rights reserved.