private void CheckWorkbookGrouping(IWorkbook wb, bool?[] collapsed, bool[] hidden, int[] outlineLevel) { printWorkbook(wb); ISheet sheet = wb.GetSheetAt(0); Assert.AreEqual(collapsed.Length, hidden.Length); Assert.AreEqual(collapsed.Length, outlineLevel.Length); Assert.AreEqual(collapsed.Length, sheet.LastRowNum - sheet.FirstRowNum + 1, "Expected " + collapsed.Length + " rows with collapsed state, but had " + (sheet.LastRowNum - sheet.FirstRowNum + 1) + " rows (" + sheet.FirstRowNum + "-" + sheet.LastRowNum + ")"); for (int i = sheet.FirstRowNum; i < sheet.LastRowNum; i++) { if (collapsed[i - sheet.FirstRowNum] == null) { continue; } XSSFRow row = (XSSFRow)sheet.GetRow(i); Assert.IsNotNull(row, "Could not read row " + i); Assert.IsNotNull(row.GetCTRow(), "Could not read row " + i); Assert.AreEqual(collapsed[i - sheet.FirstRowNum], row.GetCTRow().collapsed, "Row: " + i + ": collapsed"); Assert.AreEqual(hidden[i - sheet.FirstRowNum], row.GetCTRow().hidden, "Row: " + i + ": hidden"); Assert.AreEqual(outlineLevel[i - sheet.FirstRowNum], row.GetCTRow().outlineLevel, "Row: " + i + ": level"); } WriteToFile(wb); }
/** * Synchronize table headers with cell values in the parent sheet. * Headers <em>must</em> be in sync, otherwise Excel will display a * "Found unreadable content" message on startup. */ public void UpdateHeaders() { XSSFSheet sheet = (XSSFSheet)GetParent(); CellReference ref1 = GetStartCellReference() as CellReference; if (ref1 == null) { return; } int headerRow = ref1.Row; int firstHeaderColumn = ref1.Col; XSSFRow row = sheet.GetRow(headerRow) as XSSFRow; if (row != null && row.GetCTRow() != null) { int cellnum = firstHeaderColumn; foreach (CT_TableColumn col in GetCTTable().tableColumns.tableColumn) { XSSFCell cell = row.GetCell(cellnum) as XSSFCell; if (cell != null) { col.name = (cell.StringCellValue); } cellnum++; } } }