HSSFSheet fromsheet = wb.getSheetAt(0); //模版页 for(int num=0;num<addSheetNum;num++)//新增 { String numStr = String.valueOf(num+2); HSSFSheet newsheet = wb.createSheet("第"+numStr+"页"); //设置打印参数 newsheet.setMargin(HSSFSheet.TopMargin,fromsheet.getMargin(HSSFSheet.TopMargin));// 页边距(上) newsheet.setMargin(HSSFSheet.BottomMargin,fromsheet.getMargin(HSSFSheet.BottomMargin));// 页边距(下) newsheet.setMargin(HSSFSheet.LeftMargin,fromsheet.getMargin(HSSFSheet.LeftMargin) );// 页边距(左) newsheet.setMargin(HSSFSheet.RightMargin,fromsheet.getMargin(HSSFSheet.RightMargin));// 页边距(右 HSSFPrintSetup ps = newsheet.getPrintSetup(); ps.setLandscape(false); // 打印方向,true:横向,false:纵向(默认) ps.setVResolution((short)600); ps.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE); //纸张类型 SheetFunc.copyRows(wb, 0, num+1,0 , 46, 0);//复制 wb.getSheetAt(num+1).setColumnWidth((short)0, (short)2400);//256,31.38 }
转载于:https://www.cnblogs.com/zjhnl/archive/2012/05/09/2491837.html