Package org.apache.poi.hssf.model

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


                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


        FormulaShifter shifter = FormulaShifter.createForRowShift(externSheetIndex, 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

                         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

    @Test
    public void bug51675(){
        final List<Short> list = new ArrayList<Short>();
        HSSFWorkbook workbook = openSample("51675.xls");
        HSSFSheet sh = workbook.getSheetAt(0);
        InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
        PageSettingsBlock psb = (PageSettingsBlock) ish.getRecords().get(13);
        psb.visitContainedRecords(new RecordAggregate.RecordVisitor() {
            public void visitRecord(Record r) {
                list.add(r.getSid());
            }
        });
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

    //read in sample
    HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("Simple.xls");

    //check initial position
    HSSFSheet umSheet = book.getSheetAt(0);
    InternalSheet s = umSheet.getSheet();
    assertEquals("Initial active cell should be in col 0",
      (short) 0, s.getActiveCellCol());
    assertEquals("Initial active cell should be on row 1",
      1, s.getActiveCellRow());

    //modify position through HSSFCell
    HSSFCell cell = umSheet.createRow(3).createCell(2);
    cell.setAsActiveCell();
    assertEquals("After modify, active cell should be in col 2",
      (short) 2, s.getActiveCellCol());
    assertEquals("After modify, active cell should be on row 3",
      3, s.getActiveCellRow());

    //write book to temp file; read and verify that position is serialized
    book = HSSFTestDataSamples.writeOutAndReadBack(book);

    umSheet = book.getSheetAt(0);
    s = umSheet.getSheet();

    assertEquals("After serialize, active cell should be in col 2",
      (short) 2, s.getActiveCellCol());
    assertEquals("After serialize, active cell should be on row 3",
      3, s.getActiveCellRow());
  }
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

    //read in sample
    HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("Simple.xls");

    //check initial position
    HSSFSheet umSheet = book.getSheetAt(0);
    InternalSheet s = umSheet.getSheet();
    assertEquals("Initial active cell should be in col 0",
      (short) 0, s.getActiveCellCol());
    assertEquals("Initial active cell should be on row 1",
      1, s.getActiveCellRow());

    //modify position through HSSFCell
    HSSFCell cell = umSheet.createRow(3).createCell(2);
    cell.setAsActiveCell();
    assertEquals("After modify, active cell should be in col 2",
      (short) 2, s.getActiveCellCol());
    assertEquals("After modify, active cell should be on row 3",
      3, s.getActiveCellRow());

    //write book to temp file; read and verify that position is serialized
    book = HSSFTestDataSamples.writeOutAndReadBack(book);

    umSheet = book.getSheetAt(0);
    s = umSheet.getSheet();

    assertEquals("After serialize, active cell should be in col 2",
      (short) 2, s.getActiveCellCol());
    assertEquals("After serialize, active cell should be on row 3",
      3, s.getActiveCellRow());
  }
View Full Code Here

    public void testAutoFilter(){
        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

    }
View Full Code Here

    public void testAutoFilter(){
        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

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.