| | |
| | | List<String> rowList = dataList.get(i); |
| | | for (int j = 0; j < rowList.size(); j++) { |
| | | Cell cell = row.createCell(j); |
| | | cell.setCellValue(rowList.get(j)); |
| | | if(i ==0 || j==0){ |
| | | // 列宽设置 |
| | | sheet.setColumnWidth(i, rowList.get(i).length() * 2 * 256); |
| | | // 设置列头单元格 |
| | | cell.setCellStyle(hstyle); |
| | | if(i==0&&j==0){ |
| | | cell.setCellValue("数据日期"); |
| | | }else{ |
| | | cell.setCellValue(rowList.get(j)); |
| | | } |
| | | |
| | | if(i==0){ |
| | | sheet.setColumnWidth(i, rowList.get(i).length() * 2 * 256); |
| | | cell.setCellStyle(hstyle); |
| | | }else if(j==0){ |
| | | cell.setCellStyle(rowStyle); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private static CellStyle configHeaderCellStatic (SXSSFWorkbook workbook) { |
| | | CellStyle style = workbook.createCellStyle(); |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | |
| | | style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); |
| | | // 字体 |
| | | Font font = workbook.createFont(); |
| | | font.setFontHeightInPoints((short) 12); |
| | | font.setFontHeightInPoints((short) 10); |
| | | style.setFont(font); |
| | | // 设置边框 |
| | | configCellBorder(style); |