use of org.apache.poi.ss.usermodel.PrintSetup in project poi by apache.
the class FitSheetToOnePage method main.
public static void main(String[] args) throws IOException {
//or new HSSFWorkbook();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("format sheet");
PrintSetup ps = sheet.getPrintSetup();
sheet.setAutobreaks(true);
ps.setFitHeight((short) 1);
ps.setFitWidth((short) 1);
// Create various cells and rows for spreadsheet.
FileOutputStream fileOut = new FileOutputStream("fitSheetToOnePage.xlsx");
wb.write(fileOut);
fileOut.close();
wb.close();
}
use of org.apache.poi.ss.usermodel.PrintSetup in project poi by apache.
the class TestSXSSFBugs method bug49253.
/**
* Setting repeating rows and columns shouldn't break
* any print settings that were there before
*/
@Test
public void bug49253() throws Exception {
Workbook wb1 = new SXSSFWorkbook();
Workbook wb2 = new SXSSFWorkbook();
CellRangeAddress cra = CellRangeAddress.valueOf("C2:D3");
// No print settings before repeating
Sheet s1 = wb1.createSheet();
s1.setRepeatingColumns(cra);
s1.setRepeatingRows(cra);
PrintSetup ps1 = s1.getPrintSetup();
assertEquals(false, ps1.getValidSettings());
assertEquals(false, ps1.getLandscape());
// Had valid print settings before repeating
Sheet s2 = wb2.createSheet();
PrintSetup ps2 = s2.getPrintSetup();
ps2.setLandscape(false);
assertEquals(true, ps2.getValidSettings());
assertEquals(false, ps2.getLandscape());
s2.setRepeatingColumns(cra);
s2.setRepeatingRows(cra);
ps2 = s2.getPrintSetup();
assertEquals(true, ps2.getValidSettings());
assertEquals(false, ps2.getLandscape());
wb1.close();
wb2.close();
}
Aggregations