Alex B <alex.broytman <at> instinet.com> writes:
>
> Hello,
>
> I need to print my spreadsheer with given number of rows per page, but since
my
> rows are wide, I also need to fit the spreadsheet into the width of one page.
> In my code I call
>
> sheet.setAutobreaks(false);
> sheet.getPrintSetup().setFitWidth((short)1);
>
> If I want to have 10 rows per page in a worksheet with 17 rows, I call
> setRowBreak(10). However, I still end-up with four pages because worksheet
> width doesn't fit into one page and calling setFidWidth(1) seems to have no
> effect. I am able to get desired result just by calling setScale(), but I
have
> to calculate or guess the value of scale.
>
> Is it possible to get this done without using scale ?
>
> Thank for help
>
> Alex
>
To clarify:
Here is small test program:
public class PageSetup {
public static void main(String[] args) throws Exception {
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet();
sheet.setAutobreaks(false);
PrintSetup ps = sheet.getPrintSetup();
ps.setLandscape(true);
ps.setFitWidth((short)1);
ps.setPaperSize(ps.LETTER_PAPERSIZE);
for (short i=0; i<10; i++) {
Row row = sheet.createRow(i);
for (short j=0; j<15; j++ ) {
Cell cell = row.createCell(j);
cell.setCellValue("test");
}
if (i == 5) sheet.setRowBreak(i);
}
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
}
And in PageBreak view I see result like this:
Page 1 | Page 3 |
-----------------
Page 2 | Page 4 |
instead of
Page 1
------
Page 2
In Excel by manipulating "fit to ... width" and "fit to ...tall" you
automatically adjust size, so it is possible to use one way or another. But in
the example above setting "fit width" does not seem to do the same, size does
not change.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]