Search in sources :

Example 11 with RecordInputStream

use of org.apache.poi.hssf.record.RecordInputStream in project poi by apache.

the class TestPageItemRecord method testMoreThanOneInfoItem_bug46917.

public void testMoreThanOneInfoItem_bug46917() {
    byte[] data = HexRead.readFromString("01 02 03 04 05 06 07 08 09 0A 0B 0C");
    RecordInputStream in = TestcaseRecordInputStream.create(PageItemRecord.sid, data);
    PageItemRecord rec = new PageItemRecord(in);
    if (in.remaining() == 6) {
        throw new AssertionFailedError("Identified bug 46917");
    }
    assertEquals(0, in.remaining());
    assertEquals(4 + data.length, rec.getRecordSize());
}
Also used : PageItemRecord(org.apache.poi.hssf.record.pivottable.PageItemRecord) AssertionFailedError(junit.framework.AssertionFailedError) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 12 with RecordInputStream

use of org.apache.poi.hssf.record.RecordInputStream in project poi by apache.

the class TestViewFieldsRecord method confirmSerialize.

private static ViewFieldsRecord confirmSerialize(String hexDump) {
    byte[] data = HexRead.readFromString(hexDump);
    RecordInputStream in = TestcaseRecordInputStream.create(ViewFieldsRecord.sid, data);
    ViewFieldsRecord rec = new ViewFieldsRecord(in);
    assertEquals(0, in.remaining());
    assertEquals(4 + data.length, rec.getRecordSize());
    byte[] data2 = rec.serialize();
    TestcaseRecordInputStream.confirmRecordEncoding(ViewFieldsRecord.sid, data, data2);
    return rec;
}
Also used : ViewFieldsRecord(org.apache.poi.hssf.record.pivottable.ViewFieldsRecord) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream) TestcaseRecordInputStream(org.apache.poi.hssf.record.TestcaseRecordInputStream)

Example 13 with RecordInputStream

use of org.apache.poi.hssf.record.RecordInputStream in project poi by apache.

the class OldExcelExtractor method open.

private void open(DirectoryNode directory) throws IOException {
    DocumentNode book;
    try {
        book = (DocumentNode) directory.getEntry(OLD_WORKBOOK_DIR_ENTRY_NAME);
    } catch (FileNotFoundException e) {
        // some files have "Workbook" instead
        book = (DocumentNode) directory.getEntry(WORKBOOK_DIR_ENTRY_NAMES[0]);
    }
    if (book == null) {
        throw new IOException("No Excel 5/95 Book stream found");
    }
    ris = new RecordInputStream(directory.createDocumentInputStream(book));
    prepare();
}
Also used : DocumentNode(org.apache.poi.poifs.filesystem.DocumentNode) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) RecordInputStream(org.apache.poi.hssf.record.RecordInputStream)

Aggregations

RecordInputStream (org.apache.poi.hssf.record.RecordInputStream)13 TestcaseRecordInputStream (org.apache.poi.hssf.record.TestcaseRecordInputStream)9 AssertionFailedError (junit.framework.AssertionFailedError)7 RecordFormatException (org.apache.poi.hssf.record.RecordFormatException)3 ExtendedPivotTableViewFieldsRecord (org.apache.poi.hssf.record.pivottable.ExtendedPivotTableViewFieldsRecord)3 ViewFieldsRecord (org.apache.poi.hssf.record.pivottable.ViewFieldsRecord)3 PageItemRecord (org.apache.poi.hssf.record.pivottable.PageItemRecord)2 NPOIFSFileSystem (org.apache.poi.poifs.filesystem.NPOIFSFileSystem)2 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)1 AutoFilterInfoRecord (org.apache.poi.hssf.record.AutoFilterInfoRecord)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BackupRecord (org.apache.poi.hssf.record.BackupRecord)1 BlankRecord (org.apache.poi.hssf.record.BlankRecord)1 BookBoolRecord (org.apache.poi.hssf.record.BookBoolRecord)1