// Note that rows and columns for CellRangeAddress constructor have to be in ascending order
// The commented out line below will generate an error when opening the sheet:
// sheet.addMergedRegion(new CellRangeAddress(lastRow, lastRow-(rowsTobeCreated-1), 0, 0));
// In order this call works:
sheet.addMergedRegion(new CellRangeAddress(lastRow-(rowsTobeCreated-1), lastRow, 0, 0));
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
wb.setSheetName(0, "Supporting Documentation"); // make sure this is not too long
2 回答
另一个问题是,如果您使用的是addMergedRegion,则行和列的CellRangeAddress值必须按升序排列:
如果其他人遇到此问题,请检查以确保SheetName的长度不会太长 . 设置工作簿工作表名称超过大约30个字符时,我收到此错误 .