org.apache.poi.hssf.record.EOFRecord Java Examples
The following examples show how to use
org.apache.poi.hssf.record.EOFRecord.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordOrderer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Finds the index where the sheet validations header record should be inserted * @param records the records for this sheet * * + WINDOW2 * o SCL * o PANE * oo SELECTION * o STANDARDWIDTH * oo MERGEDCELLS * o LABELRANGES * o PHONETICPR * o Conditional Formatting Table * o Hyperlink Table * o Data Validity Table * o SHEETLAYOUT * o SHEETPROTECTION * o RANGEPROTECTION * + EOF */ private static int findDataValidationTableInsertPos(List<RecordBase> records) { int i = records.size() - 1; if (!(records.get(i) instanceof EOFRecord)) { throw new IllegalStateException("Last sheet record should be EOFRecord"); } while (i > 0) { i--; RecordBase rb = records.get(i); if (isDVTPriorRecord(rb)) { Record nextRec = (Record) records.get(i + 1); if (!isDVTSubsequentRecord(nextRec.getSid())) { throw new IllegalStateException("Unexpected (" + nextRec.getClass().getName() + ") found after (" + rb.getClass().getName() + ")"); } return i+1; } Record rec = (Record) rb; if (!isDVTSubsequentRecord(rec.getSid())) { throw new IllegalStateException("Unexpected (" + rec.getClass().getName() + ") while looking for DV Table insert pos"); } } return 0; }
Example #2
Source File: RecordOrderer.java From lams with GNU General Public License v2.0 | 6 votes |
/** * @return <code>true</code> if the specified record ID terminates a sequence of Row block records * It is assumed that at least one row or cell value record has been found prior to the current * record */ public static boolean isEndOfRowBlock(int sid) { switch(sid) { case ViewDefinitionRecord.sid: // should have been prefixed with DrawingRecord (0x00EC), but bug 46280 seems to allow this case DrawingRecord.sid: case DrawingSelectionRecord.sid: case ObjRecord.sid: case TextObjectRecord.sid: case ColumnInfoRecord.sid: // See Bugzilla 53984 case GutsRecord.sid: // see Bugzilla 50426 case WindowOneRecord.sid: // should really be part of workbook stream, but some apps seem to put this before WINDOW2 case WindowTwoRecord.sid: return true; case DVALRecord.sid: return true; case EOFRecord.sid: // WINDOW2 should always be present, so shouldn't have got this far throw new RuntimeException("Found EOFRecord before WindowTwoRecord was encountered"); } return PageSettingsBlock.isComponentRecord(sid); }
Example #3
Source File: RowBlock.java From dremio-oss with Apache License 2.0 | 6 votes |
/** * @return <code>true</code> if the specified record ID terminates a sequence of Row block records * It is assumed that at least one row or cell value record has been found prior to the current * record */ static boolean isEndOfRowBlock(int sid) { switch(sid) { case ViewDefinitionRecord.sid: // should have been prefixed with DrawingRecord (0x00EC), but bug 46280 seems to allow this case DrawingRecord.sid: case DrawingSelectionRecord.sid: case ObjRecord.sid: case TextObjectRecord.sid: case ColumnInfoRecord.sid: // See Bugzilla 53984 case GutsRecord.sid: // see Bugzilla 50426 case WindowOneRecord.sid: // should really be part of workbook stream, but some apps seem to put this before WINDOW2 case WindowTwoRecord.sid: return true; case DVALRecord.sid: return true; case EOFRecord.sid: // WINDOW2 should always be present, so shouldn't have got this far throw new RuntimeException("Found EOFRecord before WindowTwoRecord was encountered"); } return PageSettingsBlock.isComponentRecord(sid); }
Example #4
Source File: EventWorkbookBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Creates a stub Workbook from the supplied records, * suitable for use with the {@link HSSFFormulaParser} * @param externs The ExternSheetRecords in your file * @param bounds The BoundSheetRecords in your file * @param sst The SSTRecord in your file. * @return A stub Workbook suitable for use with {@link HSSFFormulaParser} */ public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs, BoundSheetRecord[] bounds, SSTRecord sst) { List<Record> wbRecords = new ArrayList<Record>(); // Core Workbook records go first if(bounds != null) { for (BoundSheetRecord bound : bounds) { wbRecords.add(bound); } } if(sst != null) { wbRecords.add(sst); } // Now we can have the ExternSheetRecords, // preceded by a SupBookRecord if(externs != null) { wbRecords.add(SupBookRecord.createInternalReferences( (short)externs.length)); for (ExternSheetRecord extern : externs) { wbRecords.add(extern); } } // Finally we need an EoF record wbRecords.add(EOFRecord.instance); return InternalWorkbook.createWorkbook(wbRecords); }
Example #5
Source File: RecordOrderer.java From lams with GNU General Public License v2.0 | 5 votes |
private static boolean isDVTSubsequentRecord(short sid) { switch(sid) { case UnknownRecord.SHEETEXT_0862: case UnknownRecord.SHEETPROTECTION_0867: case UnknownRecord.PLV_MAC: case FeatRecord.sid: case EOFRecord.sid: return true; } return false; }
Example #6
Source File: EofRecordHandler.java From easyexcel with Apache License 2.0 | 4 votes |
@Override public boolean couldDecode(Record record) { return EOFRecord.sid == record.getSid(); }
Example #7
Source File: InternalWorkbook.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Creates an empty workbook object with three blank sheets and all the empty * fields. Use this to create a workbook from scratch. * * @return an empty workbook object */ public static InternalWorkbook createWorkbook() { LOG.log( DEBUG, "creating new workbook from scratch" ); InternalWorkbook retval = new InternalWorkbook(); List<Record> records = new ArrayList<Record>( 30 ); retval.records.setRecords(records); List<FormatRecord> formats = retval.formats; records.add(createBOF()); records.add(new InterfaceHdrRecord(CODEPAGE)); records.add(createMMS()); records.add(InterfaceEndRecord.instance); records.add(createWriteAccess()); records.add(createCodepage()); records.add(createDSF()); records.add(createTabId()); retval.records.setTabpos(records.size() - 1); records.add(createFnGroupCount()); records.add(createWindowProtect()); records.add(createProtect()); retval.records.setProtpos(records.size() - 1); records.add(createPassword()); records.add(createProtectionRev4()); records.add(createPasswordRev4()); retval.windowOne = createWindowOne(); records.add(retval.windowOne); records.add(createBackup()); retval.records.setBackuppos(records.size() - 1); records.add(createHideObj()); records.add(createDateWindow1904()); records.add(createPrecision()); records.add(createRefreshAll()); records.add(createBookBool()); records.add(createFont()); records.add(createFont()); records.add(createFont()); records.add(createFont()); retval.records.setFontpos( records.size() - 1 ); // last font record position retval.numfonts = 4; // set up format records for (int i = 0; i <= 7; i++) { FormatRecord rec = createFormat(i); retval.maxformatid = retval.maxformatid >= rec.getIndexCode() ? retval.maxformatid : rec.getIndexCode(); formats.add(rec); records.add(rec); } for (int k = 0; k < 21; k++) { records.add(InternalWorkbook.createExtendedFormat(k)); retval.numxfs++; } retval.records.setXfpos( records.size() - 1 ); for (int k = 0; k < 6; k++) { records.add(InternalWorkbook.createStyle(k)); } records.add(InternalWorkbook.createUseSelFS()); int nBoundSheets = 1; // now just do 1 for (int k = 0; k < nBoundSheets; k++) { BoundSheetRecord bsr = createBoundSheet(k); records.add(bsr); retval.boundsheets.add(bsr); retval.records.setBspos(records.size() - 1); } records.add( InternalWorkbook.createCountry() ); for ( int k = 0; k < nBoundSheets; k++ ) { retval.getOrCreateLinkTable().checkExternSheet(k); } retval.sst = new SSTRecord(); records.add(retval.sst); records.add(InternalWorkbook.createExtendedSST()); records.add(EOFRecord.instance); LOG.log( DEBUG, "exit create new workbook from scratch" ); return retval; }