Apache POI SXSSFWorkbook - border for merged cells

I am using SXSSFWorkbook () to create my workbook. I have a requirement to concatenate multiple cells between rows / columns and also give it a border.

My problem is that merging cells without applying border works fine, however, at the moment when I try to merge cells and apply edge app apps in Exception.

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)

      

My code:

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);

      

Any help / pointers around this would be great.

+3


source to share





All Articles