POI

POI api Projects

POI api Project 1

Fit Sheet to One Page using POI
Previous Home Next

 

This page is contain an example in which we are try to set the height and width of the sheet. for performing this type of the task POI provide the setFitHeight((short)1) and setFitWidth((short)1) method. the 
setFitHeight((short)1) method help to set the height of the sheet and 
setFitWidth((short)1) method set the width of the sheet.


 setFitHeight((short)1) Is used to set the height of the sheet of any single page of the workbook.
setFitWidth((short)1) Is used to set the width of the sheet of any single page of the workbook.


 


Workbook wkb =
new HSSFWorkbook(); Sheet sheet = wkb.createSheet("sheet name"); PrintSetup pts = sheet.getPrintSetup(); sheet.setAutobreaks(true); pts.setFitHeight((short)1); pts.setFitWidth((short)1); // Create more than one cells and rows for spreadsheet. FileOutputStream ft = new FileOutputStream("workbook.xls"); wkb.write(ft); ft.close();

 


Previous Home Next