Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException


        throws IOException
    {
        FileInputStream   fin   = new FileInputStream(file);
        POIFSFileSystem   poifs = new POIFSFileSystem(fin);
        InputStream       din   = poifs.createDocumentInputStream("Workbook");
        RecordInputStream rinp  = new RecordInputStream(din);

        while(rinp.hasNextRecord()) {
           int sid  = rinp.getNextSid();
           rinp.nextRecord();
          
           int size = rinp.available();
           Class<? extends Record> clz = RecordFactory.getRecordClass(sid);
          
           System.out.print(
                 formatSID(sid) +
                 " - " +
                 formatSize(size) +
                 " bytes"
           );
           if(clz != null) {
              System.out.print("  \t");
              System.out.print(clz.getName().replace("org.apache.poi.hssf.record.", ""));
           }
           System.out.println();
          
           byte[] data = rinp.readRemainder();
           if(data.length > 0) {
              System.out.print("   ");
              System.out.println( formatData(data) );
           }
        }
View Full Code Here


  public void testSubNameNotPresent_bug46693() {
    // This data came from attachment 23347 of bug 46693 at offset 0xAA43
    byte[] data = HexRead.readFromString(
        "00 01 14 00" + // BIFF header
        "1E 14 00 0A FF FF FF FF 00 00 FF FF 00 00 00 00 00 00 00 00");
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ExtendedPivotTableViewFieldsRecord rec;
    try {
      rec = new ExtendedPivotTableViewFieldsRecord(in);
    } catch (RecordFormatException e) {
      if (e.getMessage().equals("Expected to find a ContinueRecord in order to read remaining 65535 of 65535 chars")) {
View Full Code Here

        + "2F 00 6B 00 67 00 29 00 20 00 69 00 6E 00 20 00 "
        + "36 00 30 00 25 00 20 00 50 00 45 00 47 00 20 00 "
        + "32 00 30 00 30 00 0A 00 46 00 20 00 3D 00 61 00 "
        + "62 00 63 00");

    RecordInputStream in = TestcaseRecordInputStream.create(SeriesTextRecord.sid, data);
    SeriesTextRecord str;
    try {
      str = new SeriesTextRecord(in);
    } catch (RecordFormatException e) {
      if (e.getCause() instanceof IllegalArgumentException) {
View Full Code Here

  public void testOlderFormat_bug46918() {
    // There are 10 SXVDEX records in the file (not uploaded) that originated bugzilla 46918
    // They all had the following hex encoding:
    byte data[] = HexRead.readFromString("00 01 0A 00 1E 14 00 0A FF FF FF FF 00 00")

    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ExtendedPivotTableViewFieldsRecord rec;
    try {
      rec = new ExtendedPivotTableViewFieldsRecord(in);
    } catch (RecordFormatException e) {
      if (e.getMessage().equals("Not enough data (0) to read requested (2) bytes")) {
View Full Code Here

*/
public final class TestViewFieldsRecord extends TestCase {
 
  public void testUnicodeFlag_bug46693() {
    byte[] data = HexRead.readFromString("01 00 01 00 01 00 04 00 05 00 00 6D 61 72 63 6F");
    RecordInputStream in = TestcaseRecordInputStream.create(ViewFieldsRecord.sid, data);
    ViewFieldsRecord rec = new ViewFieldsRecord(in);
    if (in.remaining() == 1) {
      throw new AssertionFailedError("Identified bug 46693b");
    }
    assertEquals(0, in.remaining());
    assertEquals(4+data.length, rec.getRecordSize());
  }
View Full Code Here

    confirmSerialize("01 00 01 00 01 00 04 00 0A 00 01 48 00 69 00 73 00 74 00 6F 00 72 00 79 00 2D 00 82 69 81 89");
  }

  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;
  }
View Full Code Here

*/
public final class TestPageItemRecord extends TestCase {
 
  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());
  }
View Full Code Here

    confirmSerialize("01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12");
  }

  private static PageItemRecord confirmSerialize(String hexDump) {
    byte[] data = HexRead.readFromString(hexDump);
    RecordInputStream in = TestcaseRecordInputStream.create(PageItemRecord.sid, data);
    PageItemRecord rec = new PageItemRecord(in);
    assertEquals(0, in.remaining());
    assertEquals(4+data.length, rec.getRecordSize());
    byte[] data2 = rec.serialize();
    TestcaseRecordInputStream.confirmRecordEncoding(PageItemRecord.sid, data, data2);
    return rec;
  }
View Full Code Here

        (byte)0x00,
        (byte)0x00,      // not sure where that last byte comes from
    };

    public void testLoad() {
        RecordInputStream in = TestcaseRecordInputStream.create(0x1044, data);
        SheetPropertiesRecord record = new SheetPropertiesRecord(in);
        if (in.remaining() == 1) {
            throw new AssertionFailedError("Identified bug 44693c");
        }
        assertEquals(0, in.remaining());
        assertEquals( 10, record.getFlags());
        assertEquals( false, record.isChartTypeManuallyFormatted() );
        assertEquals( true, record.isPlotVisibleOnly() );
        assertEquals( false, record.isDoNotSizeWithWindow() );
        assertEquals( true, record.isDefaultPlotDimensions() );
View Full Code Here

  /**
   * The correct size of a {@link ChartFormatRecord} is 20 bytes (not including header).
   */
  public void testLoad() {
    RecordInputStream in = TestcaseRecordInputStream.create(data);
    ChartFormatRecord record = new ChartFormatRecord(in);
    if (in.remaining() == 2) {
      throw new AssertionFailedError("Identified bug 44693d");
    }
    assertEquals(0, in.remaining());
    assertEquals(24, record.getRecordSize());

    byte[] data2 = record.serialize();
    assertTrue(Arrays.equals(data, data2));
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.