Package org.apache.poi.hssf.model

Examples of org.apache.poi.hssf.model.InternalSheet


     * errors are particularly hard to track down.  This test ensures that HSSFWorkbook throws
     * a specific exception as soon as the situation is detected. See bugzilla 45066
     */
    public void testSheetSerializeSizeMismatch_bug45066() {
        HSSFWorkbook wb = new HSSFWorkbook();
        InternalSheet sheet = wb.createSheet("Sheet1").getSheet();
        List<RecordBase> sheetRecords = sheet.getRecords();
        // one way (of many) to cause the discrepancy is with a badly behaved record:
        sheetRecords.add(new BadlyBehavedRecord());
        // There is also much logic inside Sheet that (if buggy) might also cause the discrepancy
        try {
            wb.getBytes();
View Full Code Here


    @Test
    public void autoFilter(){
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sh = wb.createSheet();
        InternalWorkbook iwb = wb.getWorkbook();
        InternalSheet ish = sh.getSheet();

        assertNull( iwb.getSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1) );
        assertNull( ish.findFirstRecordBySid(AutoFilterInfoRecord.sid) );

        CellRangeAddress range = CellRangeAddress.valueOf("A1:B10");
        sh.setAutoFilter(range);

        NameRecord name = iwb.getSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1);
        assertNotNull( name );

        // The built-in name for auto-filter must consist of a single Area3d Ptg.
        Ptg[] ptg = name.getNameDefinition();
        assertEquals("The built-in name for auto-filter must consist of a single Area3d Ptg", 1, ptg.length);
        assertTrue("The built-in name for auto-filter must consist of a single Area3d Ptg", ptg[0] instanceof Area3DPtg);

        Area3DPtg aref = (Area3DPtg)ptg[0];
        assertEquals(range.getFirstColumn(), aref.getFirstColumn());
        assertEquals(range.getFirstRow(), aref.getFirstRow());
        assertEquals(range.getLastColumn(), aref.getLastColumn());
        assertEquals(range.getLastRow(), aref.getLastRow());

        // verify  AutoFilterInfoRecord
        AutoFilterInfoRecord afilter = (AutoFilterInfoRecord)ish.findFirstRecordBySid(AutoFilterInfoRecord.sid);
        assertNotNull(afilter );
        assertEquals(2, afilter.getNumEntries()); //filter covers two columns

        HSSFPatriarch dr = sh.getDrawingPatriarch();
        assertNotNull(dr);
        HSSFSimpleShape comboBoxShape = (HSSFSimpleShape)dr.getChildren().get(0);
        assertEquals(comboBoxShape.getShapeType(),  HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX);

        assertNull( ish.findFirstRecordBySid(ObjRecord.sid) ); // ObjRecord will appear after serializetion

        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
        sh = wb.getSheetAt(0);
        ish = sh.getSheet();
        ObjRecord objRecord = (ObjRecord)ish.findFirstRecordBySid(ObjRecord.sid);
        List<SubRecord> subRecords = objRecord.getSubRecords();
        assertEquals(3, subRecords.size());
        assertTrue(subRecords.get(0) instanceof CommonObjectDataSubRecord );
        assertTrue(subRecords.get(1) instanceof FtCblsSubRecord ); // must be present, see Bug 51481
        assertTrue(subRecords.get(2) instanceof LbsDataSubRecord );
View Full Code Here

        HSSFSheet sh = wb.createSheet("Pictures");
        HSSFPatriarch dr = sh.createDrawingPatriarch();
        HSSFClientAnchor anchor = new HSSFClientAnchor();

        InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);

        //register a picture
        byte[] data1 = new byte[]{1, 2, 3};
        int idx1 = wb.addPicture(data1, Workbook.PICTURE_TYPE_JPEG);
        assertEquals(1, idx1);
View Full Code Here

        HSSFSheet sh = wb.createSheet("Pictures");
        HSSFPatriarch dr = sh.createDrawingPatriarch();
        HSSFClientAnchor anchor = new HSSFClientAnchor();

        InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);

        //register a picture
        byte[] data1 = new byte[]{1, 2, 3};
        int idx1 = wb.addPicture(data1, Workbook.PICTURE_TYPE_JPEG);
        assertEquals(1, idx1);
View Full Code Here

                         externSheetIndex, sheetName, startRow, endRow, n);
        _sheet.updateFormulasAfterCellShift(shifter, externSheetIndex);

        int nSheets = _workbook.getNumberOfSheets();
        for (int i = 0; i < nSheets; i++) {
            InternalSheet otherSheet = _workbook.getSheetAt(i).getSheet();
            if (otherSheet == this._sheet) {
                continue;
            }
            short otherExtSheetIx = _book.checkExternSheet(i);
            otherSheet.updateFormulasAfterCellShift(shifter, otherExtSheetIx);
        }
        _workbook.getWorkbook().updateNamesAfterCellShift(shifter);
    }
View Full Code Here

        new UserSViewEnd(HexRead.readFromString("01, 00")),

        EOFRecord.instance,
    };
    RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
    InternalSheet sheet;
    try {
      sheet = InternalSheet.createSheet(rs);
    } catch (RuntimeException e) {
      if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
        throw new AssertionFailedError("Identified bug 46480");
      }
      throw e;
    }

    RecordCollector rv = new RecordCollector();
    sheet.visitContainedRecords(rv, rowIx);
    Record[] outRecs = rv.getRecords();
    assertEquals(13, outRecs.length);
  }
View Full Code Here

        new WindowTwoRecord(),
        new HeaderFooterRecord(HexRead.readFromString("9C 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 60 00 00 00 00 00 00 00 00")),
        EOFRecord.instance,
    };
    RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
    InternalSheet sheet = InternalSheet.createSheet(rs);

    RecordCollector rv = new RecordCollector();
    sheet.visitContainedRecords(rv, 0);
    Record[] outRecs = rv.getRecords();
    if (outRecs[4] == EOFRecord.instance) {
      throw new AssertionFailedError("Identified bug 46953 - EOF incorrectly appended to PSB");
    }
    assertEquals(recs.length+1, outRecs.length); // +1 for index record
View Full Code Here

        new WindowTwoRecord(),
        EOFRecord.instance,
    };
    RecordStream rs = new RecordStream(Arrays.asList(recs), 0);

    InternalSheet sheet;
    try {
      sheet = InternalSheet.createSheet(rs);
    } catch (RuntimeException e) {
      if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
        throw new AssertionFailedError("Identified bug 47199a - failed to process late margings records");
      }
      throw e;
    }

    RecordCollector rv = new RecordCollector();
    sheet.visitContainedRecords(rv, 0);
    Record[] outRecs = rv.getRecords();
    assertEquals(recs.length+1, outRecs.length); // +1 for index record

    assertEquals(BOFRecord.class, outRecs[0].getClass());
    assertEquals(IndexRecord.class, outRecs[1].getClass());
View Full Code Here

                new HeaderFooterRecord(HexRead.readFromString("9C 08 00 00 00 00 00 00 00 00 00 00 53 CE BD CC DE 38 44 45 97 C1 5C 89 F9 37 32 1B 34 33 00 00 00 00 00 00 00 00")),

                EOFRecord.instance,
        };
        RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
        InternalSheet sheet;
        try {
            sheet = InternalSheet.createSheet(rs);
        } catch (RuntimeException e) {
            if (e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x89c)")) {
                throw new AssertionFailedError("Identified bug 48026");
            }
            throw e;
        }

        RecordCollector rv = new RecordCollector();
        sheet.visitContainedRecords(rv, 0);
        Record[] outRecs = rv.getRecords();

        assertEquals(recs.length, outRecs.length);
        //expected order of records:
        Record[] expectedRecs = {
View Full Code Here

        // convert all LabelRecord records to LabelSSTRecord
        convertLabelRecords(records, recOffset);
        RecordStream rs = new RecordStream(records, recOffset);
        while (rs.hasNext()) {
            try {
                InternalSheet sheet = InternalSheet.createSheet(rs);
                _sheets.add(new HSSFSheet(this, sheet));
            } catch (UnsupportedBOFType eb) {
                // Hopefully there's a supported one after this!
                log.log(POILogger.WARN, "Unsupported BOF found of type " + eb.getType());
            }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.model.InternalSheet

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.