C# Excel and Text-Based Files SpreadsheetGear API Sample
Excel-Compatible Samples for .NET
Description
Open Excel-compatible workbook files from disk or network drive using the SpreadsheetGear.Factory.GetWorkbook(string pathToFile) method.
An overloaded version of this method is available (SpreadsheetGear.Factory.GetWorkbook(string pathToFile, CultureInfo cultureInfo)) if you need to specify what regional settings (i.e., System.Globalization.CultureInfo) should be used for various locale-sensitive workbook content (e.g., NumberFormats for cells) when opening the file. If no CultureInfo object is specified, the "en-US" CultureInfo will be used.
If you have already created an IWorkbookSet object, you can also open workbook files from disk or network drive within your IWorkbookSet object by using the IWorkbookSet.Workbooks.Open(string pathToFile) method.
IWorkbookSet.Workbooks.Open(string pathToFile, string password) method that accepts a password as the second argument. See also the Workbook Encryption (Password Protected) SpreadsheetGear API Sample for a demo of this API.SpreadsheetGear supports opening the following Excel-compatible file formats:
- Excel 2007-2025 Open XML (*.xlsx)
- Excel 2007-2025 Macro-Enabled Open XML (*.xlsm)
- Excel 97-2003 (*.xls)
- ASCII CSV / Comma-Delimited (typically saved with *.csv extension)
- Unicode Text Tab-Delimited (typically saved with *.txt extension)