📄 workbook.java
字号:
/** * 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); break; case 10 : 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 11 : 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 12 : 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 13 : 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 14 : 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; // cell records case 15 : retval.setFontIndex(( short ) 0); retval.setFormatIndex(( short ) 0); retval.setCellOptions(( short ) 0x1); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0x0); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; // style case 16 : retval.setFontIndex(( short ) 1); retval.setFormatIndex(( short ) 0x2b); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff800); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 17 : retval.setFontIndex(( short ) 1); retval.setFormatIndex(( short ) 0x29); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff800); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 18 : retval.setFontIndex(( short ) 1); retval.setFormatIndex(( short ) 0x2c); retval.setCellOptions(( short ) 0xfffffff5); retval.setAlignmentOptions(( short ) 0x20); retval.setIndentionOptions(( short ) 0xfffff800); retval.setBorderOptions(( short ) 0); retval.setPaletteOptions(( short ) 0); retval.setAdtlPaletteOptions(( short ) 0); retval.setFillPaletteOptions(( short ) 0x20c0); break; case 19 : retval.setFontIndex(( short ) 1); retval.setFormatIndex(( short ) 0x2a); retval.setCellOptions(( short ) 0xfffffff5);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -