You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Zihao Yu <zi...@gmail.com> on 2010/09/14 21:25:45 UTC

set Excel print fit to page width

My application generates a excel file with many rows. I want to set it fit
to page width. Here is my code:

workbook.setRepeatingRowsAndColumns(SomeRow, SomeCol); // Make header repeat
on each printout page.
HSSFPrintSetup ps = hsf.sheet.getPrintSetup();
ps.setLandscape(true);
sheet.setAutoBreaks(true);
ps.setFitWidth((short)1);

After the file is generated, I go to print preview in Excel. The preview is
in landscape, but the sheet is scaled to fit only the left half of the page.
The text is very small. What is the correct way to do this? Thanks.

Zihao

Re: set Excel print fit to page width

Posted by kgiovanna <ka...@gmail.com>.
Hi, 

Not sure if you ever solve this issue, I had the same issue and found my
answer in here:
http://www.roseindia.net/jsp/poi/repeatingRowsAndColums.shtml

pretty much if you just want to repeat the first row as the header you
should do something like this:

workbook.SetRepeatingRowsAndColumns(0, -1, -1, 0, 0);

to just set the repeating row. (-1 is like using null it will be ignored)



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/set-Excel-print-fit-to-page-width-tp2839699p5713142.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org