using System; using GemBox.Spreadsheet; namespace Samples { /// <summary> /// Reading sample. /// </summary> class ReadingSamplesCS { [STAThread] static void Main(string[] args) { // TODO: If using GemBox.Spreadsheet Professional, put your serial key below. // Otherwise, if you are using GemBox.Spreadsheet Free, comment out the // following line (Free version doesn't have SetLicense method). // SpreadsheetInfo.SetLicense("YOUR-SERIAL-KEY-HERE"); ExcelFile ef = new ExcelFile(); ef.LoadXls("..\\..\\TestWorkbook.xls"); // Uncomment if you want to read from XLSX or ODS. Preservation option must be specified // to read cached formula values (otherwise formulas will have empty result value). // ef.LoadXlsx("..\\..\\TestWorkbook.xlsx", XlsxOptions.PreserveMakeCopy); // ef.LoadOds("..\\..\\TestWorkbook.ods", OdsOptions.PreserveMakeCopy); foreach (ExcelWorksheet sheet in ef.Worksheets) { Console.WriteLine("--------- {0} ---------", sheet.Name); foreach (ExcelRow row in sheet.Rows) { foreach (ExcelCell cell in row.AllocatedCells) { if (cell.Value != null) Console.Write("{0}({1})", cell.Value, cell.Value.GetType().Name); Console.Write("\t"); } Console.WriteLine(); } } Console.ReadLine(); } } }