Search in sources :

Example 1 with WindowTwoRecord

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

the class InternalSheet method createWindowTwo.

/**
     * creates the WindowTwo Record and sets it to:  <P>
     * options        = 0x6b6 <P>
     * toprow         = 0 <P>
     * leftcol        = 0 <P>
     * headercolor    = 0x40 <P>
     * pagebreakzoom  = 0x0 <P>
     * normalzoom     = 0x0 <p>
     */
private static WindowTwoRecord createWindowTwo() {
    WindowTwoRecord retval = new WindowTwoRecord();
    retval.setOptions((short) 0x6b6);
    retval.setTopRow((short) 0);
    retval.setLeftCol((short) 0);
    retval.setHeaderColor(0x40);
    retval.setPageBreakZoom((short) 0);
    retval.setNormalZoom((short) 0);
    return retval;
}
Also used : WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord)

Example 2 with WindowTwoRecord

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

the class TestSheet method testCreateSheet.

@Test
public void testCreateSheet() {
    // Check we're adding row and cell aggregates
    List<Record> records = new ArrayList<Record>();
    records.add(BOFRecord.createSheetBOF());
    records.add(new DimensionsRecord());
    records.add(createWindow2Record());
    records.add(EOFRecord.instance);
    InternalSheet sheet = createSheet(records);
    Record[] outRecs = getSheetRecords(sheet, 0);
    int pos = 0;
    assertTrue(outRecs[pos++] instanceof BOFRecord);
    assertTrue(outRecs[pos++] instanceof IndexRecord);
    assertTrue(outRecs[pos++] instanceof DimensionsRecord);
    assertTrue(outRecs[pos++] instanceof WindowTwoRecord);
    assertTrue(outRecs[pos++] instanceof EOFRecord);
}
Also used : EOFRecord(org.apache.poi.hssf.record.EOFRecord) ArrayList(java.util.ArrayList) StringRecord(org.apache.poi.hssf.record.StringRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) Test(org.junit.Test)

Example 3 with WindowTwoRecord

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

the class TestValueRecordsAggregate method testSharedFormula.

/**
	 * Make sure the shared formula DOESNT makes it to the FormulaRecordAggregate when being parsed
	 * as part of the value records
	 */
@Test
public void testSharedFormula() {
    List<Record> records = new ArrayList<Record>();
    records.add(new FormulaRecord());
    records.add(new SharedFormulaRecord());
    records.add(new WindowTwoRecord());
    constructValueRecord(records);
    List<CellValueRecordInterface> cvrs = getValueRecords();
    //Ensure that the SharedFormulaRecord has been converted
    assertEquals(1, cvrs.size());
    CellValueRecordInterface record = cvrs.get(0);
    assertNotNull("Row contains a value", record);
    assertTrue("First record is a FormulaRecordsAggregate", (record instanceof FormulaRecordAggregate));
}
Also used : SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) CellValueRecordInterface(org.apache.poi.hssf.record.CellValueRecordInterface) ArrayList(java.util.ArrayList) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) Record(org.apache.poi.hssf.record.Record) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) Test(org.junit.Test)

Example 4 with WindowTwoRecord

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

the class TestValueRecordsAggregate method testData.

private static List<Record> testData() {
    List<Record> records = new ArrayList<Record>();
    FormulaRecord formulaRecord = new FormulaRecord();
    BlankRecord blankRecord = new BlankRecord();
    formulaRecord.setRow(1);
    formulaRecord.setColumn((short) 1);
    blankRecord.setRow(2);
    blankRecord.setColumn((short) 2);
    records.add(formulaRecord);
    records.add(blankRecord);
    records.add(new WindowTwoRecord());
    return records;
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) ArrayList(java.util.ArrayList) Record(org.apache.poi.hssf.record.Record) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord)

Example 5 with WindowTwoRecord

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

the class TestDrawingAggregate method testSerializeDrawingBigger8k.

/**
     * Try to check file with such record sequence
     * ...
     * DrawingRecord
     * ContinueRecord
     * ObjRecord | TextObjRecord
     * ...
     */
@Test
public void testSerializeDrawingBigger8k() throws IOException {
    HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls");
    InternalWorkbook iworkbook = HSSFTestHelper.getWorkbookForTest(wb);
    HSSFSheet sh = wb.getSheetAt(0);
    InternalSheet isheet = HSSFTestHelper.getSheetForTest(sh);
    List<RecordBase> records = isheet.getRecords();
    // the sheet's drawing is not aggregated
    assertEquals("wrong size of sheet records stream", 32, records.size());
    // the last record before the drawing block
    assertTrue("records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(), records.get(18) instanceof RowRecordsAggregate);
    // records to be aggregated
    List<RecordBase> dgRecords = records.subList(19, 26);
    for (RecordBase rb : dgRecords) {
        Record r = (Record) rb;
        short sid = r.getSid();
        // we expect that drawing block consists of either
        // DrawingRecord or ContinueRecord or ObjRecord or TextObjectRecord
        assertTrue(sid == DrawingRecord.sid || sid == ContinueRecord.sid || sid == ObjRecord.sid || sid == NoteRecord.sid || sid == TextObjectRecord.sid);
    }
    // collect drawing records into a byte buffer.
    byte[] dgBytes = toByteArray(dgRecords);
    // the first record after the drawing block
    assertTrue("records.get(26) is expected to be Window2", records.get(26) instanceof WindowTwoRecord);
    // aggregate drawing records.
    // The subrange [19, 38] is expected to be replaced with a EscherAggregate object
    DrawingManager2 drawingManager = iworkbook.findDrawingGroup();
    int loc = isheet.aggregateDrawingRecords(drawingManager, false);
    EscherAggregate agg = (EscherAggregate) records.get(loc);
    assertEquals("wrong size of the aggregated sheet records stream", 26, records.size());
    assertTrue("records.get(18) is expected to be RowRecordsAggregate but was " + records.get(18).getClass().getSimpleName(), records.get(18) instanceof RowRecordsAggregate);
    assertTrue("records.get(19) is expected to be EscherAggregate but was " + records.get(19).getClass().getSimpleName(), records.get(19) instanceof EscherAggregate);
    assertTrue("records.get(20) is expected to be Window2 but was " + records.get(20).getClass().getSimpleName(), records.get(20) instanceof WindowTwoRecord);
    byte[] dgBytesAfterSave = agg.serialize();
    assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
    assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave));
    wb.close();
}
Also used : WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) RowRecordsAggregate(org.apache.poi.hssf.record.aggregates.RowRecordsAggregate) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) EscherAggregate(org.apache.poi.hssf.record.EscherAggregate) RecordBase(org.apache.poi.hssf.record.RecordBase) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) ContinueRecord(org.apache.poi.hssf.record.ContinueRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) Test(org.junit.Test)

Aggregations

WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)10 Record (org.apache.poi.hssf.record.Record)8 Test (org.junit.Test)7 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)5 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)5 EOFRecord (org.apache.poi.hssf.record.EOFRecord)5 NoteRecord (org.apache.poi.hssf.record.NoteRecord)5 ObjRecord (org.apache.poi.hssf.record.ObjRecord)5 TextObjectRecord (org.apache.poi.hssf.record.TextObjectRecord)5 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)4 EscherRecord (org.apache.poi.ddf.EscherRecord)4 ContinueRecord (org.apache.poi.hssf.record.ContinueRecord)4 EscherAggregate (org.apache.poi.hssf.record.EscherAggregate)4 RecordBase (org.apache.poi.hssf.record.RecordBase)4 RowRecordsAggregate (org.apache.poi.hssf.record.aggregates.RowRecordsAggregate)4 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)4 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)4 ArrayList (java.util.ArrayList)3 BlankRecord (org.apache.poi.hssf.record.BlankRecord)3 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)3