Commit b09e420da1b76a4dff940aebefa56f7f85883b4a

Authored by 娄高锋
1 parent bba6c6f5

创建cellStyle超过4000上限,打创建方法拿到了外面

src/main/java/com/bsth/util/ReportUtils.java
... ... @@ -194,7 +194,7 @@ public class ReportUtils {
194 194 // 创建新行
195 195 newRow = sheet.createRow(index + k++);
196 196 // 把新行的内容换成和模板行一样
197   - copyRow(wb, orgRow, newRow, true);
  197 + copyRow(wb, orgRow, newRow, true, wb.createCellStyle());
198 198 tmpCellNum = newRow.getLastCellNum();
199 199 for (int l = 0; l < tmpCellNum; l++) {
200 200 cell = newRow.getCell(l);
... ... @@ -357,11 +357,11 @@ public class ReportUtils {
357 357 * @param toRow
358 358 */
359 359 private void copyRow(HSSFWorkbook wb, HSSFRow fromRow, HSSFRow toRow,
360   - boolean copyValueFlag) {
  360 + boolean copyValueFlag, HSSFCellStyle style) {
361 361 for (Iterator<Cell> cellIt = fromRow.cellIterator(); cellIt.hasNext();) {
362 362 HSSFCell tmpCell = (HSSFCell) cellIt.next();
363 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 374 * true则连同cell的内容一起复制
375 375 */
376 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 379 copyCellStyle(wb, srcCell.getCellStyle(), newstyle);
380 380 // 样式
381 381 distCell.setCellStyle(newstyle);
... ...