📄 workbook.java
字号:
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; } /** * creates the BookBool record with saveLinkValues set to 0. (don't save link values) * @see org.apache.poi.hssf.record.BookBoolRecord * @see org.apache.poi.hssf.record.Record * @return record containing a BookBoolRecord */ protected Record createBookBool() { BookBoolRecord retval = new BookBoolRecord(); retval.setSaveLinkValues(( short ) 0); return retval; } /** * creates a Font record with the following magic values: <P> * fontheight = 0xc8<P> * attributes = 0x0<P> * color palette index = 0x7fff<P> * bold weight = 0x190<P> * Font Name Length = 5 <P> * Font Name = Arial <P> * * @see org.apache.poi.hssf.record.FontRecord * @see org.apache.poi.hssf.record.Record * @return record containing a FontRecord */ protected Record createFont() { FontRecord retval = new FontRecord(); retval.setFontHeight(( short ) 0xc8); retval.setAttributes(( short ) 0x0); retval.setColorPaletteIndex(( short ) 0x7fff); retval.setBoldWeight(( short ) 0x190); retval.setFontNameLength(( byte ) 5); retval.setFontName("Arial"); return retval; } /** * Creates a FormatRecord object * @param id the number of the format record to create (meaning its position in * a file as M$ Excel would create it.) * @return record containing a FormatRecord * @see org.apache.poi.hssf.record.FormatRecord * @see org.apache.poi.hssf.record.Record */ protected Record createFormat(int id) { // we'll need multiple editions for FormatRecord retval = new FormatRecord(); // the differnt formats switch (id) { case 0 : retval.setIndexCode(( short ) 5); retval.setFormatStringLength(( byte ) 0x17); retval.setFormatString("\"$\"#,##0_);\\(\"$\"#,##0\\)"); break; case 1 : retval.setIndexCode(( short ) 6); retval.setFormatStringLength(( byte ) 0x1c); retval.setFormatString("\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)"); break; case 2 : retval.setIndexCode(( short ) 7); retval.setFormatStringLength(( byte ) 0x1d); retval.setFormatString("\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)"); break; case 3 : retval.setIndexCode(( short ) 8); retval.setFormatStringLength(( byte ) 0x22); retval.setFormatString( "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)"); break; case 4 : retval.setIndexCode(( short ) 0x2a); retval.setFormatStringLength(( byte ) 0x32); retval.setFormatString( "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)"); break; case 5 : retval.setIndexCode(( short ) 0x29); retval.setFormatStringLength(( byte ) 0x29); retval.setFormatString( "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)"); break; case 6 : retval.setIndexCode(( short ) 0x2c); retval.setFormatStringLength(( byte ) 0x3a); retval.setFormatString( "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)"); break; case 7 : retval.setIndexCode(( short ) 0x2b); retval.setFormatStringLength(( byte ) 0x31); retval.setFormatString( "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)"); break; } return retval; } /** * Creates an ExtendedFormatRecord object * @param id the number of the extended format record to create (meaning its position in * a file as MS Excel would create it.) * * @return record containing an ExtendedFormatRecord * @see org.apache.poi.hssf.record.ExtendedFormatRecord * @see org.apache.poi.hssf.record.Record */ protected Record createExtendedFormat(int id) { // we'll need multiple editions ExtendedFormatRecord retval = new ExtendedFormatRecord(); switch (id) { case 0 : retval.setFontIndex(( short ) 0); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 1 : retval.setFontIndex(( short ) 1); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 2 : retval.setFontIndex(( short ) 1); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 3 : retval.setFontIndex(( short ) 2); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 4 : retval.setFontIndex(( short ) 2); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 5 : retval.setFontIndex(( short ) 0); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 6 : retval.setFontIndex(( short ) 0); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 7 : retval.setFontIndex(( short ) 0); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 8 : retval.setFontIndex(( short ) 0); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 9 : retval.setFontIndex(( short ) 0); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff400); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -