hssfsheet.java
来自「EXCEL read and write」· Java 代码 · 共 1,858 行 · 第 1/5 页
JAVA
1,858 行
} /** * Get the DVRecords objects that are associated to this sheet * @return a list of DVRecord instances */ public List getDVRecords() { List dvRecords = new ArrayList(); List records = sheet.getRecords(); for(int index=0; index<records.size(); index++) { if(records.get(index) instanceof DVRecord) { dvRecords.add(records.get(index)); } } return dvRecords; } /** * @deprecated (Sep 2008) use {@link #setColumnHidden(int, boolean)} */ public void setColumnHidden(short columnIndex, boolean hidden) { setColumnHidden(columnIndex & 0xFFFF, hidden); } /** * @deprecated (Sep 2008) use {@link #isColumnHidden(int)} */ public boolean isColumnHidden(short columnIndex) { return isColumnHidden(columnIndex & 0xFFFF); } /** * @deprecated (Sep 2008) use {@link #setColumnWidth(int, int)} */ public void setColumnWidth(short columnIndex, short width) { setColumnWidth(columnIndex & 0xFFFF, width & 0xFFFF); } /** * @deprecated (Sep 2008) use {@link #getColumnWidth(int)} */ public short getColumnWidth(short columnIndex) { return (short)getColumnWidth(columnIndex & 0xFFFF); } /** * @deprecated (Sep 2008) use {@link #setDefaultColumnWidth(int)} */ public void setDefaultColumnWidth(short width) { setDefaultColumnWidth(width & 0xFFFF); } /** * Get the visibility state for a given column. * @param columnIndex - the column to get (0-based) * @param hidden - the visiblity state of the column */ public void setColumnHidden(int columnIndex, boolean hidden) { sheet.setColumnHidden(columnIndex, hidden); } /** * Get the hidden state for a given column. * @param columnIndex - the column to set (0-based) * @return hidden - <code>false</code> if the column is visible */ public boolean isColumnHidden(int columnIndex) { return sheet.isColumnHidden(columnIndex); } /** * set the width (in units of 1/256th of a character width) * @param columnIndex - the column to set (0-based) * @param width - the width in units of 1/256th of a character width */ public void setColumnWidth(int columnIndex, int width) { sheet.setColumnWidth(columnIndex, width); } /** * get the width (in units of 1/256th of a character width ) * @param columnIndex - the column to set (0-based) * @return width - the width in units of 1/256th of a character width */ public int getColumnWidth(int columnIndex) { return sheet.getColumnWidth(columnIndex); } /** * get the default column width for the sheet (if the columns do not define their own width) in * characters * @return default column width */ public int getDefaultColumnWidth() { return sheet.getDefaultColumnWidth(); } /** * set the default column width for the sheet (if the columns do not define their own width) in * characters * @param width default column width */ public void setDefaultColumnWidth(int width) { sheet.setDefaultColumnWidth(width); } /** * get the default row height for the sheet (if the rows do not define their own height) in * twips (1/20 of a point) * @return default row height */ public short getDefaultRowHeight() { return sheet.getDefaultRowHeight(); } /** * get the default row height for the sheet (if the rows do not define their own height) in * points. * @return default row height in points */ public float getDefaultRowHeightInPoints() { return (sheet.getDefaultRowHeight() / 20); } /** * set the default row height for the sheet (if the rows do not define their own height) in * twips (1/20 of a point) * @param height default row height */ public void setDefaultRowHeight(short height) { sheet.setDefaultRowHeight(height); } /** * set the default row height for the sheet (if the rows do not define their own height) in * points * @param height default row height */ public void setDefaultRowHeightInPoints(float height) { sheet.setDefaultRowHeight((short) (height * 20)); } /** * get whether gridlines are printed. * @return true if printed */ public boolean isGridsPrinted() { return sheet.isGridsPrinted(); } /** * set whether gridlines printed. * @param value false if not printed. */ public void setGridsPrinted(boolean value) { sheet.setGridsPrinted(value); } /** * @deprecated (Aug-2008) use <tt>CellRangeAddress</tt> instead of <tt>Region</tt> */ public int addMergedRegion(Region region) { return sheet.addMergedRegion( region.getRowFrom(), region.getColumnFrom(), //(short) region.getRowTo(), region.getRowTo(), region.getColumnTo()); } /** * adds a merged region of cells (hence those cells form one) * @param region (rowfrom/colfrom-rowto/colto) to merge * @return index of this region */ public int addMergedRegion(CellRangeAddress region) { return sheet.addMergedRegion( region.getFirstRow(), region.getFirstColumn(), region.getLastRow(), region.getLastColumn()); } /** * Whether a record must be inserted or not at generation to indicate that * formula must be recalculated when workbook is opened. * @param value true if an uncalced record must be inserted or not at generation */ public void setForceFormulaRecalculation(boolean value) { sheet.setUncalced(value); } /** * Whether a record must be inserted or not at generation to indicate that * formula must be recalculated when workbook is opened. * @return true if an uncalced record must be inserted or not at generation */ public boolean getForceFormulaRecalculation() { return sheet.getUncalced(); } /** * determines whether the output is vertically centered on the page. * @param value true to vertically center, false otherwise. */ public void setVerticallyCenter(boolean value) { sheet.getPageSettings().getVCenter().setVCenter(value); } /** * TODO: Boolean not needed, remove after next release * @deprecated (Mar-2008) use getVerticallyCenter() instead */ public boolean getVerticallyCenter(boolean value) { return getVerticallyCenter(); } /** * Determine whether printed output for this sheet will be vertically centered. */ public boolean getVerticallyCenter() { return sheet.getPageSettings().getVCenter().getVCenter(); } /** * determines whether the output is horizontally centered on the page. * @param value true to horizontally center, false otherwise. */ public void setHorizontallyCenter(boolean value) { sheet.getPageSettings().getHCenter().setHCenter(value); } /** * Determine whether printed output for this sheet will be horizontally centered. */ public boolean getHorizontallyCenter() { return sheet.getPageSettings().getHCenter().getHCenter(); } /** * removes a merged region of cells (hence letting them free) * @param index of the region to unmerge */ public void removeMergedRegion(int index) { sheet.removeMergedRegion(index); } /** * returns the number of merged regions * @return number of merged regions */ public int getNumMergedRegions() { return sheet.getNumMergedRegions(); } /** * @deprecated (Aug-2008) use {@link HSSFSheet#getMergedRegion(int)} */ public Region getMergedRegionAt(int index) { CellRangeAddress cra = getMergedRegion(index); return new Region(cra.getFirstRow(), (short)cra.getFirstColumn(), cra.getLastRow(), (short)cra.getLastColumn()); } /** * @return the merged region at the specified index */ public CellRangeAddress getMergedRegion(int index) { return sheet.getMergedRegionAt(index); } /** * @return an iterator of the PHYSICAL rows. Meaning the 3rd element may not * be the third row if say for instance the second row is undefined. * Call getRowNum() on each row if you care which one it is. */ public Iterator rowIterator() { return rows.values().iterator(); } /** * Alias for {@link #rowIterator()} to allow * foreach loops */ public Iterator iterator() { return rowIterator(); } /** * used internally in the API to get the low level Sheet record represented by this * Object. * @return Sheet - low level representation of this HSSFSheet. */ protected Sheet getSheet() { return sheet; } /** * whether alternate expression evaluation is on * @param b alternative expression evaluation or not */ public void setAlternativeExpression(boolean b) { WSBoolRecord record = (WSBoolRecord) sheet.findFirstRecordBySid(WSBoolRecord.sid); record.setAlternateExpression(b); } /** * whether alternative formula entry is on * @param b alternative formulas or not */ public void setAlternativeFormula(boolean b) { WSBoolRecord record = (WSBoolRecord) sheet.findFirstRecordBySid(WSBoolRecord.sid); record.setAlternateFormula(b); } /** * show automatic page breaks or not * @param b whether to show auto page breaks */ public void setAutobreaks(boolean b) { WSBoolRecord record = (WSBoolRecord) sheet.findFirstRecordBySid(WSBoolRecord.sid); record.setAutobreaks(b); } /** * set whether sheet is a dialog sheet or not * @param b isDialog or not */ public void setDialog(boolean b)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?