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

📄 sheet.java

📁 java 报表 to office文档: 本包由java语言开发
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    {        checkRows();        if (log.check( POILogger.DEBUG ))            log.log(POILogger.DEBUG, "addRow ");        DimensionsRecord d = ( DimensionsRecord ) records.get(getDimsLoc());        if (row.getRowNumber() >= d.getLastRow())        {            d.setLastRow(row.getRowNumber() + 1);        }        if (row.getRowNumber() < d.getFirstRow())        {            d.setFirstRow(row.getRowNumber());        }        //IndexRecord index = null;         //If the row exists remove it, so that any cells attached to the row are removed         RowRecord existingRow = rows.getRow(row.getRowNumber());         if (existingRow != null)           rows.removeRow(existingRow);        rows.insertRow(row);        /*         * for (int k = loc; k < records.size(); k++)         * {         *   Record rec = ( Record ) records.get(k);         *         *   if (rec.getSid() == IndexRecord.sid)         *   {         *       index = ( IndexRecord ) rec;         *   }         *   if (rec.getSid() == RowRecord.sid)         *   {         *       RowRecord rowrec = ( RowRecord ) rec;         *         *       if (rowrec.getRowNumber() > row.getRowNumber())         *       {         *           records.add(k, row);         *           loc = k;         *           break;         *       }         *   }         *   if (rec.getSid() == WindowTwoRecord.sid)         *   {         *       records.add(k, row);         *       loc = k;         *       break;         *   }         * }         * if (index != null)         * {         *   if (index.getLastRowAdd1() <= row.getRowNumber())         *   {         *       index.setLastRowAdd1(row.getRowNumber() + 1);         *   }         * }         */        if (log.check( POILogger.DEBUG ))            log.log(POILogger.DEBUG, "exit addRow");    }    /**     * Removes a row record     *     * This method is not loc sensitive, it resets loc to = dimsloc so no worries.     *     * @param row  the row record to remove     */    public void removeRow(RowRecord row)    {        checkRows();        // IndexRecord index = null;        setLoc(getDimsLoc());        rows.removeRow(row);        /*         * for (int k = loc; k < records.size(); k++)         * {         *   Record rec = ( Record ) records.get(k);         *         *   // checkDimsLoc(rec,k);         *   if (rec.getSid() == RowRecord.sid)         *   {         *       RowRecord rowrec = ( RowRecord ) rec;         *         *       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()    {        if (log.check( POILogger.DEBUG ))            log.log(POILogger.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()    {        POILogger.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()    {        if (log.check( POILogger.DEBUG ))            log.log(POILogger.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)    {        if (log.check( POILogger.DEBUG ))            log.log(POILogger.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;    }    /**     * 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(RefModeRecord.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     * @see org.apache.poi.hssf.record.Record     * @return record containing a IterationRecord     */    protected Record createIteration()    {        IterationRecord retval = new IterationRecord();        retval.setIteration(false);

⌨️ 快捷键说明

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