use of org.apache.poi.hssf.record.aggregates.PageSettingsBlock in project poi by apache.
the class InternalSheet method getPageSettings.
public PageSettingsBlock getPageSettings() {
if (_psBlock == null) {
_psBlock = new PageSettingsBlock();
RecordOrderer.addNewSheetRecord(_records, _psBlock);
}
return _psBlock;
}
use of org.apache.poi.hssf.record.aggregates.PageSettingsBlock in project poi by apache.
the class TestBugs method bug51675.
@Test
public void bug51675() throws Exception {
final List<Short> list = new ArrayList<Short>();
HSSFWorkbook wb = openSample("51675.xls");
HSSFSheet sh = wb.getSheetAt(0);
InternalSheet ish = HSSFTestHelper.getSheetForTest(sh);
PageSettingsBlock psb = (PageSettingsBlock) ish.getRecords().get(13);
psb.visitContainedRecords(new RecordAggregate.RecordVisitor() {
@Override
public void visitRecord(Record r) {
list.add(r.getSid());
}
});
assertEquals(UnknownRecord.BITMAP_00E9, list.get(list.size() - 1).intValue());
assertEquals(UnknownRecord.HEADER_FOOTER_089C, list.get(list.size() - 2).intValue());
wb.close();
}
use of org.apache.poi.hssf.record.aggregates.PageSettingsBlock in project poi by apache.
the class TestSheet method testColPageBreaks.
/**
* Make sure column pag breaks works properly (in-memory)
*
*/
@Test
public void testColPageBreaks() {
short rowFrom = 0;
short rowTo = (short) 65535;
InternalSheet worksheet = InternalSheet.createSheet();
PageSettingsBlock sheet = worksheet.getPageSettings();
sheet.setColumnBreak((short) 0, rowFrom, rowTo);
assertTrue("no col break at 0", sheet.isColumnBroken(0));
assertEquals("1 col break available", 1, sheet.getNumColumnBreaks());
sheet.setColumnBreak((short) 0, rowFrom, rowTo);
assertTrue("no col break at 0", sheet.isColumnBroken(0));
assertEquals("1 col break available", 1, sheet.getNumColumnBreaks());
sheet.setColumnBreak((short) 1, rowFrom, rowTo);
sheet.setColumnBreak((short) 10, rowFrom, rowTo);
sheet.setColumnBreak((short) 15, rowFrom, rowTo);
assertTrue("no col break at 1", sheet.isColumnBroken(1));
assertTrue("no col break at 10", sheet.isColumnBroken(10));
assertTrue("no col break at 15", sheet.isColumnBroken(15));
assertEquals("4 col break available", 4, sheet.getNumColumnBreaks());
boolean is10 = false;
boolean is0 = false;
boolean is1 = false;
boolean is15 = false;
int[] colBreaks = sheet.getColumnBreaks();
for (int main : colBreaks) {
if (main != 0 && main != 1 && main != 10 && main != 15)
fail("Invalid page break");
if (main == 0)
is0 = true;
if (main == 1)
is1 = true;
if (main == 10)
is10 = true;
if (main == 15)
is15 = true;
}
assertTrue("one of the breaks didnt make it", is0 && is1 && is10 && is15);
sheet.removeColumnBreak(15);
assertFalse("column break should not be there", sheet.isColumnBroken(15));
sheet.removeColumnBreak(0);
assertFalse("column break should not be there", sheet.isColumnBroken(0));
sheet.removeColumnBreak(1);
assertFalse("column break should not be there", sheet.isColumnBroken(1));
sheet.removeColumnBreak(10);
assertFalse("column break should not be there", sheet.isColumnBroken(10));
assertEquals("no more breaks", 0, sheet.getNumColumnBreaks());
}
use of org.apache.poi.hssf.record.aggregates.PageSettingsBlock in project poi by apache.
the class TestSheet method testRowPageBreaks.
/**
* Make sure page break functionality works (in memory)
*
*/
@Test
public void testRowPageBreaks() {
short colFrom = 0;
short colTo = 255;
InternalSheet worksheet = InternalSheet.createSheet();
PageSettingsBlock sheet = worksheet.getPageSettings();
sheet.setRowBreak(0, colFrom, colTo);
assertTrue("no row break at 0", sheet.isRowBroken(0));
assertEquals("1 row break available", 1, sheet.getNumRowBreaks());
sheet.setRowBreak(0, colFrom, colTo);
sheet.setRowBreak(0, colFrom, colTo);
assertTrue("no row break at 0", sheet.isRowBroken(0));
assertEquals("1 row break available", 1, sheet.getNumRowBreaks());
sheet.setRowBreak(10, colFrom, colTo);
sheet.setRowBreak(11, colFrom, colTo);
assertTrue("no row break at 10", sheet.isRowBroken(10));
assertTrue("no row break at 11", sheet.isRowBroken(11));
assertEquals("3 row break available", 3, sheet.getNumRowBreaks());
boolean is10 = false;
boolean is0 = false;
boolean is11 = false;
int[] rowBreaks = sheet.getRowBreaks();
for (int main : rowBreaks) {
if (main != 0 && main != 10 && main != 11)
fail("Invalid page break");
if (main == 0)
is0 = true;
if (main == 10)
is10 = true;
if (main == 11)
is11 = true;
}
assertTrue("one of the breaks didnt make it", is0 && is10 && is11);
sheet.removeRowBreak(11);
assertFalse("row should be removed", sheet.isRowBroken(11));
sheet.removeRowBreak(0);
assertFalse("row should be removed", sheet.isRowBroken(0));
sheet.removeRowBreak(10);
assertFalse("row should be removed", sheet.isRowBroken(10));
assertEquals("no more breaks", 0, sheet.getNumRowBreaks());
}
Aggregations