Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache POI setPrintArea to A4 page size

I'm working with the Apache POI API to generate .xls files, and I want to set the printArea of my file.

I know there is a funcion called setPrintArea() but this one receive as parameters start and end row and column of my print area.

I want to know, if there is a way to set my print area for each sheet with the size of an A4 paper (210mmx290mm)

Thanks.

like image 604
ibaneight Avatar asked Apr 03 '13 10:04

ibaneight


1 Answers

For each Sheet in the workbook, get its PrintSetup object and call setPaperSize on it, passing the appropriate PrintSetup constant: A4_PAPERSIZE.

mySheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
like image 163
rgettman Avatar answered Oct 13 '22 16:10

rgettman