/// <summary> /// Resolves the workbook with all worksheets from the loaded file /// </summary> /// <returns>Workbook object</returns> public Workbook GetWorkbook() { Workbook wb = new Workbook(false); wb.SetImportState(true); Worksheet ws; foreach (KeyValuePair <int, WorksheetReader> reader in worksheets) { WorkbookReader.WorksheetDefinition definition = workbook.WorksheetDefinitions[reader.Key]; ws = new Worksheet(definition.WorksheetName, definition.SheetID, wb); ws.Hidden = definition.Hidden; foreach (KeyValuePair <string, Cell> cell in reader.Value.Data) { cell.Value.WorksheetReference = ws; if (reader.Value.StyleAssignment.ContainsKey(cell.Key)) { Style style = styleReaderContainer.GetStyle(reader.Value.StyleAssignment[cell.Key], true); if (style != null) { cell.Value.SetStyle(style); } } ws.AddCell(cell.Value, cell.Key); } wb.AddWorksheet(ws); } wb.SetImportState(false); return(wb); }
/// <summary> /// Resolves the workbook with all worksheets from the loaded file /// </summary> /// <returns>Workbook object</returns> public Workbook GetWorkbook() { Workbook wb = new Workbook(false); Worksheet ws; int index = 1; foreach (KeyValuePair <int, WorksheetReader> reader in worksheets) { ws = new Worksheet(workbook.WorksheetDefinitions[reader.Key], index, wb); foreach (KeyValuePair <string, Cell> cell in reader.Value.Data) { cell.Value.WorksheetReference = ws; if (reader.Value.StyleAssignment.ContainsKey(cell.Key)) { Style style = styleReaderContainer.GetStyle(reader.Value.StyleAssignment[cell.Key], true); if (style != null) { cell.Value.SetStyle(style); } } ws.AddCell(cell.Value, cell.Key); } wb.AddWorksheet(ws); index++; } return(wb); }
/// <summary> /// Determine which of the resolved styles are either to define a time or a date. Stores also the styles into a dictionary /// </summary> /// <param name="styleReaderContainer">Resolved styles from the style reader</param> private void processStyles(StyleReaderContainer styleReaderContainer) { dateStyles = new List <string>(); timeStyles = new List <string>(); for (int i = 0; i < styleReaderContainer.StyleCount; i++) { bool isDate; bool isTime; styleReaderContainer.GetStyle(i, out isDate, out isTime, true); if (isDate) { dateStyles.Add(i.ToString("G", CultureInfo.InvariantCulture)); } if (isTime) { timeStyles.Add(i.ToString("G", CultureInfo.InvariantCulture)); } } }