天天看點

Apache POI(7):列印區域(PrintArea)

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)