Apache POI SXSSFWorkbook - 合并单元格的边框

时间:2015-06-03 08:05:09

标签: apache-poi

我使用SXSSFWorkbook()来创建我的工作簿。我需要跨行/列合并几个单元格,并给它一个边框。

我的问题是:将单元格合并而不应用边框非常合适,但是,当我尝试合并单元格并将边框应用程序应用到异常时。

ERROR view - java.lang.IllegalArgumentException: Attempting to write a row[2] in the range [0,204] that is already written to disk.
java.lang.IllegalArgumentException: Attempting to write a row[2] in the range [0,204] that is already written to disk.
at org.apache.poi.xssf.streaming.SXSSFSheet.createRow(SXSSFSheet.java:113)
at org.apache.poi.ss.util.CellUtil.getRow(CellUtil.java:90)
at org.apache.poi.ss.util.RegionUtil.setRightBorderColor(RegionUtil.java:139)

我的代码:

CellRangeAddress rangeAdd = new CellRangeAddress(2, 41, 0, 0);
sheet.addMergedRegion(rangeAdd);
RegionUtil.setRightBorderColor(IndexedColors.BLACK.getIndex(), rangeAdd, sheet, mWb);
RegionUtil.setTopBorderColor(IndexedColors.BLACK.getIndex(), rangeAdd, sheet, mWb);
RegionUtil.setLeftBorderColor(IndexedColors.BLACK.getIndex(), rangeAdd, sheet, mWb);
RegionUtil.setBottomBorderColor(IndexedColors.BLACK.getIndex(), rangeAdd, sheet, mWb);

RegionUtil.setBorderBottom(CellStyle.BORDER_THIN, rangeAdd, sheet, mWb);
RegionUtil.setBorderLeft(CellStyle.BORDER_THIN, rangeAdd, sheet, mWb);
RegionUtil.setBorderRight(CellStyle.BORDER_THIN, rangeAdd, sheet, mWb);
RegionUtil.setBorderTop(CellStyle.BORDER_THIN, rangeAdd, sheet, mWb);

任何关于此的帮助/指示都会很棒。

0 个答案:

没有答案