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


     * 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

    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

        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

                         .getJavaDate(firstCell.getNumericCellValue(), false));
        HSSFRow  row  = sheet.createRow(15);
        HSSFCell cell = row.createCell(1);

        cell.setCellValue(22);
        InternalSheet newSheet = workbook.getSheetAt(0).getSheet();
        List  records  = newSheet.getRecords();

        assertTrue(records.get(0) instanceof BOFRecord);
        assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
    }
View Full Code Here

    assertEquals(0, countFR);
    assertEquals(0, countFRH);
   
    // Now check on the sheet
    HSSFSheet s = hssf.getSheetAt(0);
    InternalSheet sheet = HSSFTestHelper.getSheetForTest(s);
   
    for(RecordBase rb : sheet.getRecords()) {
      if(rb instanceof Record) {
        Record r = (Record)rb;
        if(r instanceof FeatRecord) {
          countFR++;
        } else if (r.getSid() == FeatRecord.sid) {
View Full Code Here

    assertEquals(0, countFR);
    assertEquals(0, countFRH);
   
    // Now find it on our sheet
    HSSFSheet s = hssf.getSheetAt(0);
    InternalSheet sheet = HSSFTestHelper.getSheetForTest(s);
   
    for(RecordBase rb : sheet.getRecords()) {
      if(rb instanceof Record) {
        Record r = (Record)rb;
        if(r instanceof FeatRecord) {
          fr = (FeatRecord)r;
          countFR++;
View Full Code Here

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

     * 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

    //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

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.