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;
}
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);
}
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));
}
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;
}
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();
}
Aggregations