/// <summary> /// Display common information about Excel worksheets /// </summary> /// <param name="excel"></param> public void DisplayWorksheetInfo(ExcelCore excel) { List <string> worksheets = excel.GetWorksheets(); Console.WriteLine("List of available worksheets in file \"{0}\":", excel.FileName); foreach (String name in worksheets) { Console.WriteLine("\t\"{0}\"", name); ExcelObject.Worksheet worksheet = excel.GetWorksheet(name); Console.WriteLine("\tLast row with data: {0}; Last column with data: {1}\n", excel.GetCountOfRows(worksheet), excel.GetCountOfCols(worksheet) ); } }
private void RunAnalyticsProc(object o) { try { using (new WaitCursor()) { using (ExcelCore excelIn = new ExcelCore(Model.BaseModel.ExcelFileName, AppDataCore.Settings.AceVersion, Model.BaseModel.HDR)) { List <string> worksheets = excelIn.GetWorksheets(); Model.WorksheetItems.Clear(); foreach (String name in worksheets) { WorksheetItemType worksheetItem = new WorksheetItemType(); worksheetItem.WorksheetName = name; ExcelObject.Worksheet worksheet = excelIn.GetWorksheet(name); worksheetItem.RowCount = excelIn.GetCountOfRows(worksheet); worksheetItem.ColCount = excelIn.GetCountOfCols(worksheet); Model.WorksheetItems.Add(worksheetItem); } } } } catch (Exception ex) { WindowsUI.RunWindowDialog(() => { MessageBox.Show( String.Format(StringsFunctions.ResourceString("resErrorDuringOpening"), Model.BaseModel.ExcelFileName) + Environment.NewLine + Environment.NewLine + ex.Message, StringsFunctions.ResourceString("resError"), MessageBoxButton.OK, MessageBoxImage.Hand ); } ); } }