POI api Projects

POI api Project 1

Set print area for a sheet using POI
Previous Home Next


This example only show you how you can set the specific area of the sheet to print it. only POI provide the facility to performing to action on the excel sheet. it provide the setPrintArea() method which help you to do this type of the work.

In this program we are using only one setPrintArea() method for the set the print area of the sheet. we can print the specific area of the sheet and if we want to print other after first print then we are pass the next area instruction for printing by same method like setPrintArea(
            0, //index of sheet
            0, //starting column
            1, //end column
            0, //start row
            0  //end row


Workbook wkb =
new HSSFWorkbook(); Sheet sit = wkb.createSheet("Sheet1"); //setting the print area for the first sheet only. wkb.setPrintArea(0, "$A$1:$C$2"); //Alternatively: wkb.setPrintArea( 0, //sheet index 0, //start column 1, //end column 0, //start row 0 //end row ); FileOutputStream fileOut = new FileOutputStream("workbook.xls"); wkb.write(fileOut); fileOut.close();


Previous Home Next