I have an existing workbook that acts as template. I tried to update a cell value in an existing row, meaning the adjacent cell has a value. The problem is that after the file is created and I open it, I get the following error: "Excel found unreadable content in...."
我有一个充当模板的现有工作簿。我尝试更新现有行中的单元格值,这意味着相邻单元格具有值。问题是,在创建文件并打开它之后,我收到以下错误:“Excel在......中发现了不可读的内容”
I assume the reason is SXSSFWorkbook only handles writing and if a row exists it cant update the contents of the row, which would entail reading and then writing - is this correct or am I experiencing a bug?
我假设原因是SXSSFWorkbook只处理写入,如果存在行,则无法更新行的内容,这将需要读取然后写入 - 这是正确的还是我遇到了错误?
Thanks
2 个解决方案
#1
3
Another issue is that if you're using addMergedRegion, the CellRangeAddress values for rows and columns have to be in ascending numerical order:
另一个问题是,如果您使用的是addMergedRegion,则行和列的CellRangeAddress值必须按升序排列:
// 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));
#2
0
In case anyone else has this problem, check to make sure the length of your SheetName is not too long. I was getting this error when setting the workbook sheet name longer than around 30 characters.
如果其他人遇到此问题,请检查以确保SheetName的长度不会太长。设置工作簿工作表名称超过30个字符时,我收到此错误。
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
wb.setSheetName(0, "Supporting Documentation"); // make sure this is not too long
#1
3
Another issue is that if you're using addMergedRegion, the CellRangeAddress values for rows and columns have to be in ascending numerical order:
另一个问题是,如果您使用的是addMergedRegion,则行和列的CellRangeAddress值必须按升序排列:
// 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));
#2
0
In case anyone else has this problem, check to make sure the length of your SheetName is not too long. I was getting this error when setting the workbook sheet name longer than around 30 characters.
如果其他人遇到此问题,请检查以确保SheetName的长度不会太长。设置工作簿工作表名称超过30个字符时,我收到此错误。
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
wb.setSheetName(0, "Supporting Documentation"); // make sure this is not too long