POI导出文件缩放至A4纸大小,poi合并单元格显示边框不完整问题

时间:2024-03-04 18:54:30
PrintSetup print = exportExcel.getSheet().getPrintSetup(); //拿到sheet对象首先
print.setFitWidth((short)1);
print.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE); //纸张类型
print.setScale((short)68);//自定义缩放①,此处100为无缩放HSSFPrintSetup
exportExcel.getSheet().setAutobreaks(false);
print.setLeftToRight(true);//列从左向右显示②
Footer footer = exportExcel.getSheet().getFooter();
footer.setRight( "Page " + HSSFFooter.page() + " of " + HSSFFooter.numPages());//






解决poi合并单元格,边框显示不完整问题
XSSFRow tableHead = sheet.createRow(2);
tableHead.setHeightInPoints(40);
Cell tableHeadCell0 = tableHead.createCell(0);
tableHeadCell0.setCellStyle(doble2);
tableHeadCell0.setCellValue("职务/姓名/周");
for (int j = 1; j <= 2; j++) {
tableHeadCell0 = tableHead.createCell(j);
tableHeadCell0.setCellStyle(doble2); //style为带边框的样式 上面有定义
tableHeadCell0.setCellValue("");
}