sheet.java

来自「EXCEL read and write」· Java 代码 · 共 1,758 行 · 第 1/5 页

JAVA
1,758
字号
     * at what this sets it to.  For this method, set loc to dimsloc to start with,     * subsequent calls will return values in (physical) sequence or NULL when you get to the end.     *     * @return CellValueRecordInterface representing the next value record or NULL if there are no more     * @see #setLoc(int)     */    public CellValueRecordInterface[] getValueRecords() {        return _rowsAggregate.getValueRecords();    }    /**     * get the NEXT RowRecord (from LOC).  The first record that is a Row record     * (starting at LOC) will be returned.     * <P>     * This method is "loc" sensitive.  Meaning you need to set LOC to where you     * want it to start searching.  If you don't know do this: setLoc(getDimsLoc).     * When adding several rows you can just start at the last one by leaving loc     * at what this sets it to.  For this method, set loc to dimsloc to start with.     * subsequent calls will return rows in (physical) sequence or NULL when you get to the end.     *     * @return RowRecord representing the next row record or NULL if there are no more     * @see #setLoc(int)     *     */    public RowRecord getNextRow() {        if (rowRecIterator == null)        {            rowRecIterator = _rowsAggregate.getIterator();        }        if (!rowRecIterator.hasNext())        {            return null;        }        return ( RowRecord ) rowRecIterator.next();    }    /**     * get the NEXT (from LOC) RowRecord where rownumber matches the given rownum.     * The first record that is a Row record (starting at LOC) that has the     * same rownum as the given rownum will be returned.     * <P>     * This method is "loc" sensitive.  Meaning you need to set LOC to where you     * want it to start searching.  If you don't know do this: setLoc(getDimsLoc).     * When adding several rows you can just start at the last one by leaving loc     * at what this sets it to.  For this method, set loc to dimsloc to start with.     * subsequent calls will return rows in (physical) sequence or NULL when you get to the end.     *     * @param rownum   which row to return (careful with LOC)     * @return RowRecord representing the next row record or NULL if there are no more     * @see #setLoc(int)     *     */    public RowRecord getRow(int rownum) {        return _rowsAggregate.getRow(rownum);    }    /**     * creates the BOF record     */    /* package */ static BOFRecord createBOF() {        BOFRecord retval = new BOFRecord();        retval.setVersion(( short ) 0x600);        retval.setType(( short ) 0x010);        retval.setBuild(( short ) 0x0dbb);        retval.setBuildYear(( short ) 1996);        retval.setHistoryBitMask(0xc1);        retval.setRequiredVersion(0x6);        return retval;    }    /**     * creates the CalcMode record and sets it to 1 (automatic formula caculation)     */    private static CalcModeRecord createCalcMode() {        CalcModeRecord retval = new CalcModeRecord();        retval.setCalcMode(( short ) 1);        return retval;    }    /**     * creates the CalcCount record and sets it to 100 (default number of iterations)     */    private static CalcCountRecord createCalcCount() {        CalcCountRecord retval = new CalcCountRecord();        retval.setIterations(( short ) 100);   // default 100 iterations        return retval;    }    /**     * creates the RefMode record and sets it to A1 Mode (default reference mode)     */    private static RefModeRecord createRefMode() {        RefModeRecord retval = new RefModeRecord();        retval.setMode(RefModeRecord.USE_A1_MODE);        return retval;    }    /**     * creates the Iteration record and sets it to false (don't iteratively calculate formulas)     */    private static IterationRecord createIteration() {        IterationRecord retval = new IterationRecord();        retval.setIteration(false);        return retval;    }    /**     * creates the Delta record and sets it to 0.0010 (default accuracy)     */    private static DeltaRecord createDelta() {        DeltaRecord retval = new DeltaRecord();        retval.setMaxChange(0.0010);        return retval;    }    /**     * creates the SaveRecalc record and sets it to true (recalculate before saving)     */    private static SaveRecalcRecord createSaveRecalc() {        SaveRecalcRecord retval = new SaveRecalcRecord();        retval.setRecalc(true);        return retval;    }    /**     * creates the PrintHeaders record and sets it to false (we don't create headers yet so why print them)     */    private static PrintHeadersRecord createPrintHeaders() {        PrintHeadersRecord retval = new PrintHeadersRecord();        retval.setPrintHeaders(false);        return retval;    }    /**     * creates the PrintGridlines record and sets it to false (that makes for ugly sheets).  As far as I can     * tell this does the same thing as the GridsetRecord     */    private static PrintGridlinesRecord createPrintGridlines() {        PrintGridlinesRecord retval = new PrintGridlinesRecord();        retval.setPrintGridlines(false);        return retval;    }    /**     * creates the Gridset record and sets it to true (user has mucked with the gridlines)     */    private static GridsetRecord createGridset() {        GridsetRecord retval = new GridsetRecord();        retval.setGridset(true);        return retval;    }    /**     * creates the Guts record and sets leftrow/topcol guttter and rowlevelmax/collevelmax to 0      */    private static GutsRecord createGuts() {        GutsRecord retval = new GutsRecord();        retval.setLeftRowGutter(( short ) 0);        retval.setTopColGutter(( short ) 0);        retval.setRowLevelMax(( short ) 0);        retval.setColLevelMax(( short ) 0);        return retval;    }    private GutsRecord getGutsRecord() {        if (_gutsRecord == null) {            GutsRecord result = createGuts();            RecordOrderer.addNewSheetRecord(records, result);            _gutsRecord = result;        }        return _gutsRecord;    }    /**     * creates the DefaultRowHeight Record and sets its options to 0 and rowheight to 0xff     */    private static DefaultRowHeightRecord createDefaultRowHeight() {        DefaultRowHeightRecord retval = new DefaultRowHeightRecord();        retval.setOptionFlags(( short ) 0);        retval.setRowHeight(( short ) 0xff);        return retval;    }    /**     * creates the WSBoolRecord and sets its values to defaults     */    private static WSBoolRecord createWSBool() {        WSBoolRecord retval = new WSBoolRecord();        retval.setWSBool1(( byte ) 0x4);        retval.setWSBool2(( byte ) 0xffffffc1);        return retval;    }    /**     * creates the DefaultColWidth Record and sets it to 8      */    private static DefaultColWidthRecord createDefaultColWidth() {        DefaultColWidthRecord retval = new DefaultColWidthRecord();        retval.setColWidth(( short ) 8);        return retval;    }    /**     * get the default column width for the sheet (if the columns do not define their own width)     * @return default column width     */    public int getDefaultColumnWidth() {        return defaultcolwidth.getColWidth();    }    /**     * get whether gridlines are printed.     * @return true if printed     */    public boolean isGridsPrinted()    {        if (gridset == null) {            gridset = createGridset();            //Insert the newlycreated Gridset record at the end of the record (just before the EOF)            int loc = findFirstRecordLocBySid(EOFRecord.sid);            records.add(loc, gridset);        }        return !gridset.getGridset();    }    /**     * set whether gridlines printed or not.     * @param value     True if gridlines printed.     */    public void setGridsPrinted(boolean value)    {        gridset.setGridset(!value);    }    /**     * set the default column width for the sheet (if the columns do not define their own width)     * @param dcw  default column width     */    public void setDefaultColumnWidth(int dcw) {        defaultcolwidth.setColWidth(dcw);    }    /**     * set the default row height for the sheet (if the rows do not define their own height)     */    public void setDefaultRowHeight(short dch)    {        defaultrowheight.setRowHeight(dch);    }    /**     * get the default row height for the sheet (if the rows do not define their own height)     * @return  default row height     */    public short getDefaultRowHeight()    {        return defaultrowheight.getRowHeight();    }    /**     * get the width of a given column in units of 1/256th of a character width     * @param columnIndex index     * @see org.apache.poi.hssf.record.DefaultColWidthRecord     * @see org.apache.poi.hssf.record.ColumnInfoRecord     * @see #setColumnWidth(short,short)     * @return column width in units of 1/256th of a character width     */    public int getColumnWidth(int columnIndex) {        ColumnInfoRecord ci = _columnInfos.findColumnInfo(columnIndex);        if (ci != null) {            return ci.getColumnWidth();        }        //default column width is measured in characters        //multiply        return (256*defaultcolwidth.getColWidth());    }    /**     * get the index to the ExtendedFormatRecord "associated" with     * the column at specified 0-based index. (In this case, an     * ExtendedFormatRecord index is actually associated with a     * ColumnInfoRecord which spans 1 or more columns)     * <br/>     * Returns the index to the default ExtendedFormatRecord (0xF)     * if no ColumnInfoRecord exists that includes the column     * index specified.     * @param columnIndex     * @return index of ExtendedFormatRecord associated with     * ColumnInfoRecord that includes the column index or the     * index of the default ExtendedFormatRecord (0xF)     */    public short getXFIndexForColAt(short columnIndex) {        ColumnInfoRecord ci = _columnInfos.findColumnInfo(columnIndex);        if (ci != null) {            return (short)ci.getXFIndex();        }        return 0xF;    }    /**     * set the width for a given column in 1/256th of a character width units     *     * @param column -     *            the column number     * @param width     *            (in units of 1/256th of a character width)     */    public void setColumnWidth(int column, int width) {        setColumn(column, null, new Integer(width), null, null, null);    }    /**     * Get the hidden property for a given column.     * @param column index     * @see org.apache.poi.hssf.record.DefaultColWidthRecord     * @see org.apache.poi.hssf.record.ColumnInfoRecord     * @see #setColumnHidden(short,boolean)     * @return whether the column is hidden or not.     */    public boolean isColumnHidden(int columnIndex) {        ColumnInfoRecord cir = _columnInfos.findColumnInfo(columnIndex);        if (cir == null) {            return false;        }        return cir.getHidden();    }    /**     * Get the hidden property for a given column.     * @param column - the column number     * @param hidden - whether the column is hidden or not

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?