GemBox Software Home  
 
 
  FAQ
  Help
  Bugs & Features
  Articles  
 



How to Access XLS, XLSX and CSV files from your .NET applications?

Following example shows how to access XLS, XLSX or CSV 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 loads Excel file (in XLS format) and shows messageBox with value from cell "A1":

C# code:

ExcelFile ef = new ExcelFile();

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

// Selects first worksheet.
ExcelWorksheet ws = ef.Worksheets[0];
           
// Displays the value of first cell in the messageBox.
MessageBox.Show(ws.Cells["A1"].Value.ToString());


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)

' Displays the value of first cell in the messageBox.
MessageBox.Show(ws.Cells("A1").Value.ToString())


To access the file from another format you only need to replace the LoadXls method with preferred one (LoadXlsx or LoadCsv).
















 

© GemBox Software. All rights reserved.