⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sheet.java

📁 Office格式转换代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
         *         *       if (rowrec.getRowNumber() == row.getRowNumber())         *       {         *           records.remove(k);         *           break;         *       }         *   }         *   if (rec.getSid() == WindowTwoRecord.sid)         *   {         *       break;         *   }         * }         */    }    /**     * get the NEXT value record (from LOC).  The first record that is a value 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 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 getNextValueRecord()    {        log.log(log.DEBUG, "getNextValue loc= " + loc);        if (valueRecIterator == null)        {            valueRecIterator = cells.getIterator();        }        if (!valueRecIterator.hasNext())        {            return null;        }        return ( CellValueRecordInterface ) valueRecIterator.next();        /*         *      if (this.getLoc() < records.size())         *     {         *         for (int k = getLoc(); k < records.size(); k++)         *         {         *             Record rec = ( Record ) records.get(k);         *         *             this.setLoc(k + 1);         *             if (rec instanceof CellValueRecordInterface)         *             {         *                 return ( CellValueRecordInterface ) rec;         *             }         *         }         *     }         *     return null;         */    }    /**     * get the NEXT RowRecord or CellValueRecord(from LOC).  The first record that     * is a Row record or CellValueRecord(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 CellValueRecordInterface     *  representing the next cellvalue or NULL if there are no more     * @see #setLoc(int)     *     *//*    public Record getNextRowOrValue()    {        log.debug((new StringBuffer("getNextRow loc= ")).append(loc)            .toString());        if (this.getLoc() < records.size())        {            for (int k = this.getLoc(); k < records.size(); k++)            {                Record rec = ( Record ) records.get(k);                this.setLoc(k + 1);                if (rec.getSid() == RowRecord.sid)                {                    return rec;                }                else if (rec.isValue())                {                    return rec;                }            }        }        return null;    } */    /**     * 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()    {        log.log(log.DEBUG, "getNextRow loc= " + loc);        if (rowRecIterator == null)        {            rowRecIterator = rows.getIterator();        }        if (!rowRecIterator.hasNext())        {            return null;        }        return ( RowRecord ) rowRecIterator.next();/*        if (this.getLoc() < records.size())        {            for (int k = this.getLoc(); k < records.size(); k++)            {                Record rec = ( Record ) records.get(k);                this.setLoc(k + 1);                if (rec.getSid() == RowRecord.sid)                {                    return ( RowRecord ) rec;                }            }        }*/    }    /**     * 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(short rownum)    public RowRecord getRow(int rownum)    {        log.log(log.DEBUG, "getNextRow loc= " + loc);        return rows.getRow(rownum);        /*         * if (this.getLoc() < records.size())         * {         *   for (int k = this.getLoc(); k < records.size(); k++)         *   {         *       Record rec = ( Record ) records.get(k);         *         *       this.setLoc(k + 1);         *       if (rec.getSid() == RowRecord.sid)         *       {         *           if ((( RowRecord ) rec).getRowNumber() == rownum)         *           {         *               return ( RowRecord ) rec;         *           }         *       }         *   }         * }         */        // return null;    }    /**     * Not currently used method to calculate and add dbcell records     *     */    public void addDBCellRecords()    {        int         offset        = 0;        int         recnum        = 0;        int         rownum        = 0;        //int         lastrow       = 0;        //long        lastrowoffset = 0;        IndexRecord index         = null;        // ArrayList rowOffsets = new ArrayList();        IntList     rowOffsets    = new IntList();        for (recnum = 0; recnum < records.size(); recnum++)        {            Record rec = ( Record ) records.get(recnum);            if (rec.getSid() == IndexRecord.sid)            {                index = ( IndexRecord ) rec;            }            if (rec.getSid() != RowRecord.sid)            {                offset += rec.serialize().length;            }            else            {                break;            }        }        // First Row Record        for (; recnum < records.size(); recnum++)        {            Record rec = ( Record ) records.get(recnum);            if (rec.getSid() == RowRecord.sid)            {                rownum++;                rowOffsets.add(offset);                if ((rownum % 32) == 0)                {                    // if this is the last rec in a  dbcell block                    // find the next row or last value record                    for (int rn = recnum; rn < records.size(); rn++)                    {                        rec = ( Record ) records.get(rn);                        if ((!rec.isInValueSection())                                || (rec.getSid() == RowRecord.sid))                        {                            // here is the next row or last value record                            records.add(rn,                                        createDBCell(offset, rowOffsets,                                                     index));                            recnum = rn;                            break;                        }                    }                }                else                {                }            }            if (!rec.isInValueSection())            {                records.add(recnum, createDBCell(offset, rowOffsets, index));                break;            }            offset += rec.serialize().length;        }    }    /** not currently used */    private DBCellRecord createDBCell(int offset, IntList rowoffsets,                                      IndexRecord index)    {        DBCellRecord rec = new DBCellRecord();        rec.setRowOffset(offset - rowoffsets.get(0));        // test hack        rec.addCellOffset(( short ) 0x0);        // end test hack        addDbCellToIndex(offset, index);        return rec;    }    /** not currently used */    private void addDbCellToIndex(int offset, IndexRecord index)    {        int numdbcells = index.getNumDbcells() + 1;        index.addDbcell(offset + preoffset);        // stupid but whenever we add an offset that causes everything to be shifted down 4        for (int k = 0; k < numdbcells; k++)        {            int dbval = index.getDbcellAt(k);            index.setDbcell(k, dbval + 4);        }    }    /**     * creates the BOF record     * @see org.apache.poi.hssf.record.BOFRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a BOFRecord     */    protected Record createBOF()    {        BOFRecord retval = new BOFRecord();        retval.setVersion(( short ) 0x600);        retval.setType(( short ) 0x010);        // retval.setBuild((short)0x10d3);        retval.setBuild(( short ) 0x0dbb);        retval.setBuildYear(( short ) 1996);        retval.setHistoryBitMask(0xc1);        retval.setRequiredVersion(0x6);        return retval;    }    /**     * creates the Index record  - not currently used     * @see org.apache.poi.hssf.record.IndexRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a IndexRecord     */    protected Record createIndex()    {        IndexRecord retval = new IndexRecord();        retval.setFirstRow(0);   // must be set explicitly        retval.setLastRowAdd1(0);        return retval;    }    /**     * creates the CalcMode record and sets it to 1 (automatic formula caculation)     * @see org.apache.poi.hssf.record.CalcModeRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a CalcModeRecord     */    protected Record createCalcMode()    {        CalcModeRecord retval = new CalcModeRecord();        retval.setCalcMode(( short ) 1);        return retval;    }    /**     * creates the CalcCount record and sets it to 0x64 (default number of iterations)     * @see org.apache.poi.hssf.record.CalcCountRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a CalcCountRecord     */    protected Record createCalcCount()    {        CalcCountRecord retval = new CalcCountRecord();        retval.setIterations(( short ) 0x64);   // default 64 iterations        return retval;    }    /**     * creates the RefMode record and sets it to A1 Mode (default reference mode)     * @see org.apache.poi.hssf.record.RefModeRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a RefModeRecord     */    protected Record createRefMode()    {        RefModeRecord retval = new RefModeRecord();        retval.setMode(retval.USE_A1_MODE);        return retval;    }    /**     * creates the Iteration record and sets it to false (don't iteratively calculate formulas)     * @see org.apache.poi.hssf.record.IterationRecord

⌨️ 快捷键说明

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