public static void printArea() throws Exception{
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Print Area");
//set print area with indexes
workbook.setPrintArea(
0, //sheet index
0, //start column
5, //end column
0, //start row
5 //end row
);
//set paper size
sheet.getPrintSetup().setPaperSize(XSSFPrintSetup.A4_PAPERSIZE);
//set display grid lines or not
sheet.setDisplayGridlines(true);
FileOutputStream fos = new FileOutputStream(new File("printarea.xlsx"));
workbook.write(fos);
fos.close();
System.out.println("printarea.xlsx written successfully");
}
Apache POI(7):打印区域(PrintArea)
最新推荐文章于 2024-11-04 14:54:55 发布