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

📄 workbook.java

📁 Office格式转换代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        int pos = 0;        SSTRecord sst = null;        int sstPos = 0;        for ( int k = 0; k < records.size(); k++ )        {            Record record = records.get( k );            // Let's skip RECALCID records, as they are only use for optimization            if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )            {                if (record instanceof SSTRecord)                {                    sst = (SSTRecord)record;                    sstPos = pos;                }                if (record.getSid() == ExtSSTRecord.sid && sst != null)                {                    record = sst.createExtSSTRecord(sstPos + offset);                }                pos += record.serialize( pos + offset, data );   // rec.length;            }        }        log.log( DEBUG, "Exiting serialize workbook" );        return pos;    }    public int getSize()    {        int retval = 0;        SSTRecord sst = null;        for ( int k = 0; k < records.size(); k++ )        {            Record record = records.get( k );            // Let's skip RECALCID records, as they are only use for optimization            if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )            {                if (record instanceof SSTRecord)                    sst = (SSTRecord)record;                if (record.getSid() == ExtSSTRecord.sid && sst != null)                    retval += sst.calcExtSSTRecordSize();                else                    retval += record.getRecordSize();            }        }        return retval;    }    /**     * 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 ) 5);        retval.setBuild(( short ) 0x10d3);        //        retval.setBuild((short)0x0dbb);        retval.setBuildYear(( short ) 1996);        retval.setHistoryBitMask(0x41);   // was c1 before verify        retval.setRequiredVersion(0x6);        return retval;    }    /**     * creates the InterfaceHdr record     * @see org.apache.poi.hssf.record.InterfaceHdrRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a InterfaceHdrRecord     */    protected Record createInterfaceHdr() {        InterfaceHdrRecord retval = new InterfaceHdrRecord();        retval.setCodepage(CODEPAGE);        return retval;    }    /**     * creates an MMS record     * @see org.apache.poi.hssf.record.MMSRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a MMSRecord     */    protected Record createMMS() {        MMSRecord retval = new MMSRecord();        retval.setAddMenuCount(( byte ) 0);        retval.setDelMenuCount(( byte ) 0);        return retval;    }    /**     * creates the InterfaceEnd record     * @see org.apache.poi.hssf.record.InterfaceEndRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a InterfaceEndRecord     */    protected Record createInterfaceEnd() {        return new InterfaceEndRecord();    }    /**     * creates the WriteAccess record containing the logged in user's name     * @see org.apache.poi.hssf.record.WriteAccessRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a WriteAccessRecord     */    protected Record createWriteAccess() {        WriteAccessRecord retval = new WriteAccessRecord();        retval.setUsername(System.getProperty("user.name"));        return retval;    }    /**     * creates the Codepage record containing the constant stored in CODEPAGE     * @see org.apache.poi.hssf.record.CodepageRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a CodepageRecord     */    protected Record createCodepage() {        CodepageRecord retval = new CodepageRecord();        retval.setCodepage(CODEPAGE);        return retval;    }    /**     * creates the DSF record containing a 0 since HSSF can't even create Dual Stream Files     * @see org.apache.poi.hssf.record.DSFRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a DSFRecord     */    protected Record createDSF() {        DSFRecord retval = new DSFRecord();        retval.setDsf(        ( short ) 0);   // we don't even support double stream files        return retval;    }    /**     * creates the TabId record containing an array of 0,1,2.  This release of HSSF     * always has the default three sheets, no less, no more.     * @see org.apache.poi.hssf.record.TabIdRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a TabIdRecord     */    protected Record createTabId() {        TabIdRecord retval     = new TabIdRecord();        short[]     tabidarray = {            0        };        retval.setTabIdArray(tabidarray);        return retval;    }    /**     * creates the FnGroupCount record containing the Magic number constant of 14.     * @see org.apache.poi.hssf.record.FnGroupCountRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a FnGroupCountRecord     */    protected Record createFnGroupCount() {        FnGroupCountRecord retval = new FnGroupCountRecord();        retval.setCount(( short ) 14);        return retval;    }    /**     * creates the WindowProtect record with protect set to false.     * @see org.apache.poi.hssf.record.WindowProtectRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a WindowProtectRecord     */    protected Record createWindowProtect() {        WindowProtectRecord retval = new WindowProtectRecord();        retval.setProtect(        false);   // by default even when we support it we won't        return retval;   // want it to be protected    }    /**     * creates the Protect record with protect set to false.     * @see org.apache.poi.hssf.record.ProtectRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a ProtectRecord     */    protected Record createProtect() {        ProtectRecord retval = new ProtectRecord();        retval.setProtect(        false);   // by default even when we support it we won't        return retval;   // want it to be protected    }    /**     * creates the Password record with password set to 0.     * @see org.apache.poi.hssf.record.PasswordRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a PasswordRecord     */    protected Record createPassword() {        PasswordRecord retval = new PasswordRecord();        retval.setPassword(( short ) 0);   // no password by default!        return retval;    }    /**     * creates the ProtectionRev4 record with protect set to false.     * @see org.apache.poi.hssf.record.ProtectionRev4Record     * @see org.apache.poi.hssf.record.Record     * @return record containing a ProtectionRev4Record     */    protected Record createProtectionRev4() {        ProtectionRev4Record retval = new ProtectionRev4Record();        retval.setProtect(false);        return retval;    }    /**     * creates the PasswordRev4 record with password set to 0.     * @see org.apache.poi.hssf.record.PasswordRev4Record     * @see org.apache.poi.hssf.record.Record     * @return record containing a PasswordRev4Record     */    protected Record createPasswordRev4() {        PasswordRev4Record retval = new PasswordRev4Record();        retval.setPassword(( short ) 0);   // no password by default!        return retval;    }    /**     * creates the WindowOne record with the following magic values: <P>     * horizontal hold - 0x168 <P>     * vertical hold   - 0x10e <P>     * width           - 0x3a5c <P>     * height          - 0x23be <P>     * options         - 0x38 <P>     * selected tab    - 0 <P>     * displayed tab   - 0 <P>     * num selected tab- 0 <P>     * tab width ratio - 0x258 <P>     * @see org.apache.poi.hssf.record.WindowOneRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a WindowOneRecord     */    protected Record createWindowOne() {        WindowOneRecord retval = new WindowOneRecord();        retval.setHorizontalHold(( short ) 0x168);        retval.setVerticalHold(( short ) 0x10e);        retval.setWidth(( short ) 0x3a5c);        retval.setHeight(( short ) 0x23be);        retval.setOptions(( short ) 0x38);        retval.setSelectedTab(( short ) 0x0);        retval.setDisplayedTab(( short ) 0x0);        retval.setNumSelectedTabs(( short ) 1);        retval.setTabWidthRatio(( short ) 0x258);        return retval;    }    /**     * creates the Backup record with backup set to 0. (loose the data, who cares)     * @see org.apache.poi.hssf.record.BackupRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a BackupRecord     */    protected Record createBackup() {        BackupRecord retval = new BackupRecord();        retval.setBackup(        ( short ) 0);   // by default DONT save backups of files...just loose data        return retval;    }    /**     * creates the HideObj record with hide object set to 0. (don't hide)     * @see org.apache.poi.hssf.record.HideObjRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a HideObjRecord     */    protected Record createHideObj() {        HideObjRecord retval = new HideObjRecord();        retval.setHideObj(( short ) 0);   // by default set hide object off        return retval;    }    /**     * creates the DateWindow1904 record with windowing set to 0. (don't window)     * @see org.apache.poi.hssf.record.DateWindow1904Record     * @see org.apache.poi.hssf.record.Record     * @return record containing a DateWindow1904Record     */    protected Record createDateWindow1904() {        DateWindow1904Record retval = new DateWindow1904Record();        retval.setWindowing(        ( short ) 0);   // don't EVER use 1904 date windowing...tick tock..        return retval;    }    /**     * creates the Precision record with precision set to true. (full precision)     * @see org.apache.poi.hssf.record.PrecisionRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a PrecisionRecord     */    protected Record createPrecision() {        PrecisionRecord retval = new PrecisionRecord();        retval.setFullPrecision(        true);   // always use real numbers in calculations!        return retval;    }    /**     * creates the RefreshAll record with refreshAll set to true. (refresh all calcs)     * @see org.apache.poi.hssf.record.RefreshAllRecord     * @see org.apache.poi.hssf.record.Record     * @return record containing a RefreshAllRecord     */    protected Record createRefreshAll() {        RefreshAllRecord retval = new RefreshAllRecord();        retval.setRefreshAll(false);        return retval;    }

⌨️ 快捷键说明

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