| | |
| | | printSetup.setLandscape(false); // 纵向打印 |
| | | |
| | | // 设置页边距 |
| | | sheet.setMargin(Sheet.LeftMargin, 0.5); |
| | | sheet.setMargin(Sheet.RightMargin, 0.5); |
| | | sheet.setMargin(Sheet.LeftMargin, 0.65); |
| | | sheet.setMargin(Sheet.RightMargin, 0.65); |
| | | sheet.setMargin(Sheet.TopMargin,0.31); |
| | | sheet.setMargin(Sheet.BottomMargin, 0.31); |
| | | // 设置打印区域,从第0行到第1000行,第0列到第20列(根据实际情况调整) |
| | | // sheet.setPrintArea(0, 0, 20, 0, 1000); |
| | | // 如果是index为1的sheet,设置顶端标题行 |
| | |
| | | CellStyle underlineStyle = wb.createCellStyle(); |
| | | Font underlineFont = wb.createFont(); |
| | | underlineFont.setFontName("宋体"); |
| | | underlineFont.setFontHeightInPoints((short) 11); |
| | | underlineFont.setFontHeightInPoints((short) 12); |
| | | underlineFont.setUnderline(Font.U_SINGLE); // 设置下划线 |
| | | underlineStyle.setFont(underlineFont); |
| | | recordIdCell.setCellStyle(underlineStyle); |
| | |
| | | row = sheet.createRow(i + 5 ); |
| | | else |
| | | row = sheet.createRow(i + 1 ); |
| | | |
| | | // 得到导出对象. |
| | | T vo = (T) list.get(i); |
| | | int column = 0; |
| | |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | style.setBorderRight(BorderStyle.THIN); |
| | | style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setRightBorderColor(IndexedColors.BLACK.getIndex()); |
| | | style.setBorderLeft(BorderStyle.THIN); |
| | | style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); |
| | | style.setBorderTop(BorderStyle.THIN); |
| | | style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setTopBorderColor(IndexedColors.BLACK.getIndex()); |
| | | style.setBorderBottom(BorderStyle.THIN); |
| | | style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); |
| | | style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); |
| | | // 设置自动换行 |
| | | style.setWrapText(true); |
| | | Font dataFont = wb.createFont(); |
| | | dataFont.setFontName("Arial"); |
| | | dataFont.setFontName("宋体"); |
| | | dataFont.setFontHeightInPoints((short) 12); |
| | | style.setFont(dataFont); |
| | | styles.put("data", style); |
| | |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | style.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | Font totalFont = wb.createFont(); |
| | | totalFont.setFontName("Arial"); |
| | | totalFont.setFontName("宋体"); |
| | | totalFont.setFontHeightInPoints((short) 12); |
| | | style.setFont(totalFont); |
| | | // 总计行也设置自动换行 |
| | |
| | | // header.setFontSize((short) 10); |
| | | // 设置页眉内容 |
| | | hssfSheet.setMargin(Sheet.HeaderMargin, 2.1); |
| | | header.setRight("共 &N 页 第 &P页"); |
| | | header.setRight("&\"宋体,Bold\"共 &N 页 第 &P 页"); |
| | | } |
| | | // 如果是index为1的sheet,设置顶端标题行 |
| | | if (index == 1) { |