/** * Gets the column info record for the specified column. If no column is specified, null is * returned * * @param col the column * @return the ColumnInfoRecord if specified, NULL otherwise */ public ColumnInfoRecord getColumnInfo(int col) { if (!columnInfosInitialized) { // Initialize the array Iterator i = columnInfosArray.iterator(); ColumnInfoRecord cir = null; while (i.hasNext()) { cir = (ColumnInfoRecord) i.next(); int startcol = Math.max(0, cir.getStartColumn()); int endcol = Math.min(columnInfos.length - 1, cir.getEndColumn()); for (int c = startcol; c <= endcol; c++) { columnInfos[c] = cir; } if (endcol < startcol) { columnInfos[startcol] = cir; } } columnInfosInitialized = true; } return col < columnInfos.length ? columnInfos[col] : null; }
/** Reads in the contents of this sheet */ final void readSheet() { // If this sheet contains only a chart, then set everything to // empty and do not bother parsing the sheet // Thanks to steve.brophy for spotting this if (!sheetBof.isWorksheet()) { numRows = 0; numCols = 0; cells = new Cell[0][0]; // return; } SheetReader reader = new SheetReader( excelFile, sharedStrings, formattingRecords, sheetBof, workbookBof, nineteenFour, workbook, startPosition, this); reader.read(); // Take stuff that was read in numRows = reader.getNumRows(); numCols = reader.getNumCols(); cells = reader.getCells(); rowProperties = reader.getRowProperties(); columnInfosArray = reader.getColumnInfosArray(); hyperlinks = reader.getHyperlinks(); charts = reader.getCharts(); mergedCells = reader.getMergedCells(); header = reader.getHeader(); footer = reader.getFooter(); settings = reader.getSettings(); settings.setHidden(hidden); rowBreaks = reader.getRowBreaks(); workspaceOptions = reader.getWorkspaceOptions(); reader = null; if (!workbookSettings.getGCDisabled()) { System.gc(); } if (columnInfosArray.size() > 0) { ColumnInfoRecord cir = (ColumnInfoRecord) columnInfosArray.get(columnInfosArray.size() - 1); columnInfos = new ColumnInfoRecord[cir.getEndColumn() + 1]; } else { columnInfos = new ColumnInfoRecord[0]; } }
/** Reads in the contents of this sheet */ final void readSheet() { // If this sheet contains only a chart, then set everything to // empty and do not bother parsing the sheet // Thanks to steve.brophy for spotting this if (!sheetBof.isWorksheet()) { numRows = 0; numCols = 0; cells = new Cell[0][0]; // return; } SheetReader reader = new SheetReader( excelFile, sharedStrings, formattingRecords, sheetBof, workbookBof, nineteenFour, workbook, startPosition, this); reader.read(); // Take stuff that was read in numRows = reader.getNumRows(); numCols = reader.getNumCols(); cells = reader.getCells(); rowProperties = reader.getRowProperties(); columnInfosArray = reader.getColumnInfosArray(); hyperlinks = reader.getHyperlinks(); conditionalFormats = reader.getConditionalFormats(); autoFilter = reader.getAutoFilter(); charts = reader.getCharts(); drawings = reader.getDrawings(); dataValidation = reader.getDataValidation(); mergedCells = reader.getMergedCells(); settings = reader.getSettings(); settings.setHidden(hidden); rowBreaks = reader.getRowBreaks(); columnBreaks = reader.getColumnBreaks(); workspaceOptions = reader.getWorkspaceOptions(); plsRecord = reader.getPLS(); buttonPropertySet = reader.getButtonPropertySet(); maxRowOutlineLevel = reader.getMaxRowOutlineLevel(); maxColumnOutlineLevel = reader.getMaxColumnOutlineLevel(); reader = null; if (!workbookSettings.getGCDisabled()) { System.gc(); } if (columnInfosArray.size() > 0) { ColumnInfoRecord cir = (ColumnInfoRecord) columnInfosArray.get(columnInfosArray.size() - 1); columnInfos = new ColumnInfoRecord[cir.getEndColumn() + 1]; } else { columnInfos = new ColumnInfoRecord[0]; } // Add any local names if (localNames != null) { for (Iterator it = localNames.iterator(); it.hasNext(); ) { NameRecord nr = (NameRecord) it.next(); if (nr.getBuiltInName() == BuiltInName.PRINT_AREA) { if (nr.getRanges().length > 0) { NameRecord.NameRange rng = nr.getRanges()[0]; settings.setPrintArea( rng.getFirstColumn(), rng.getFirstRow(), rng.getLastColumn(), rng.getLastRow()); } } else if (nr.getBuiltInName() == BuiltInName.PRINT_TITLES) { // There can be 1 or 2 entries. // Row entries have hardwired column entries (first and last // possible column) // Column entries have hardwired row entries (first and last // possible row) for (int i = 0; i < nr.getRanges().length; i++) { NameRecord.NameRange rng = nr.getRanges()[i]; if (rng.getFirstColumn() == 0 && rng.getLastColumn() == 255) { settings.setPrintTitlesRow(rng.getFirstRow(), rng.getLastRow()); } else { settings.setPrintTitlesCol(rng.getFirstColumn(), rng.getLastColumn()); } } } } } }