Commit b09e420da1b76a4dff940aebefa56f7f85883b4a
1 parent
bba6c6f5
创建cellStyle超过4000上限,打创建方法拿到了外面
Showing
1 changed file
with
5 additions
and
5 deletions
src/main/java/com/bsth/util/ReportUtils.java
| @@ -194,7 +194,7 @@ public class ReportUtils { | @@ -194,7 +194,7 @@ public class ReportUtils { | ||
| 194 | // 创建新行 | 194 | // 创建新行 |
| 195 | newRow = sheet.createRow(index + k++); | 195 | newRow = sheet.createRow(index + k++); |
| 196 | // 把新行的内容换成和模板行一样 | 196 | // 把新行的内容换成和模板行一样 |
| 197 | - copyRow(wb, orgRow, newRow, true); | 197 | + copyRow(wb, orgRow, newRow, true, wb.createCellStyle()); |
| 198 | tmpCellNum = newRow.getLastCellNum(); | 198 | tmpCellNum = newRow.getLastCellNum(); |
| 199 | for (int l = 0; l < tmpCellNum; l++) { | 199 | for (int l = 0; l < tmpCellNum; l++) { |
| 200 | cell = newRow.getCell(l); | 200 | cell = newRow.getCell(l); |
| @@ -357,11 +357,11 @@ public class ReportUtils { | @@ -357,11 +357,11 @@ public class ReportUtils { | ||
| 357 | * @param toRow | 357 | * @param toRow |
| 358 | */ | 358 | */ |
| 359 | private void copyRow(HSSFWorkbook wb, HSSFRow fromRow, HSSFRow toRow, | 359 | private void copyRow(HSSFWorkbook wb, HSSFRow fromRow, HSSFRow toRow, |
| 360 | - boolean copyValueFlag) { | 360 | + boolean copyValueFlag, HSSFCellStyle style) { |
| 361 | for (Iterator<Cell> cellIt = fromRow.cellIterator(); cellIt.hasNext();) { | 361 | for (Iterator<Cell> cellIt = fromRow.cellIterator(); cellIt.hasNext();) { |
| 362 | HSSFCell tmpCell = (HSSFCell) cellIt.next(); | 362 | HSSFCell tmpCell = (HSSFCell) cellIt.next(); |
| 363 | HSSFCell newCell = toRow.createCell(tmpCell.getColumnIndex(), 0); | 363 | HSSFCell newCell = toRow.createCell(tmpCell.getColumnIndex(), 0); |
| 364 | - copyCell(wb, tmpCell, newCell, copyValueFlag); | 364 | + copyCell(wb, tmpCell, newCell, copyValueFlag, style); |
| 365 | } | 365 | } |
| 366 | } | 366 | } |
| 367 | 367 | ||
| @@ -374,8 +374,8 @@ public class ReportUtils { | @@ -374,8 +374,8 @@ public class ReportUtils { | ||
| 374 | * true则连同cell的内容一起复制 | 374 | * true则连同cell的内容一起复制 |
| 375 | */ | 375 | */ |
| 376 | public void copyCell(HSSFWorkbook wb, HSSFCell srcCell, HSSFCell distCell, | 376 | public void copyCell(HSSFWorkbook wb, HSSFCell srcCell, HSSFCell distCell, |
| 377 | - boolean copyValueFlag) { | ||
| 378 | - HSSFCellStyle newstyle = wb.createCellStyle(); | 377 | + boolean copyValueFlag, HSSFCellStyle newstyle) { |
| 378 | +// HSSFCellStyle newstyle = wb.createCellStyle(); | ||
| 379 | copyCellStyle(wb, srcCell.getCellStyle(), newstyle); | 379 | copyCellStyle(wb, srcCell.getCellStyle(), newstyle); |
| 380 | // 样式 | 380 | // 样式 |
| 381 | distCell.setCellStyle(newstyle); | 381 | distCell.setCellStyle(newstyle); |