Other API Samples

Live SpreadsheetGear API Samples

Workbook Opening Excel and Text-Based Files

SpreadsheetGear supports opening the following file formats:

  • Excel 2007-2019 Open XML (*.xlsx and *.xlsm)
  • Excel 97-2003 (*.xls)
  • CSV and Unicode Text (tab-delimited)
// SpreadsheetGear will automatically detect the file format and open it accordingly.
SpreadsheetGear.IWorkbook workbook1 = SpreadsheetGear.Factory.GetWorkbook(@"c:\path\to\workbook1.xlsx");
SpreadsheetGear.IWorkbook workbook2 = SpreadsheetGear.Factory.GetWorkbook(@"c:\path\to\workbook2.xlsm");
SpreadsheetGear.IWorkbook workbook3 = SpreadsheetGear.Factory.GetWorkbook(@"c:\path\to\workbook3.xls");
SpreadsheetGear.IWorkbook workbook4 = SpreadsheetGear.Factory.GetWorkbook(@"c:\path\to\data.csv");
SpreadsheetGear.IWorkbook workbook5 = SpreadsheetGear.Factory.GetWorkbook(@"c:\path\to\data.txt");