Created attachment 23215 [details] Testing file I use following codes to open an Excel file, then call "sheet.shiftRows", but the output file cannot be opened by MS Excel. It prompted "Unable to read file." error message. -- HSSFWorkbook wb = new HSSFWorkbook(ExcelUtil.fixInputStream(new FileInputStream("unable_to_read_file.xls"))); HSSFSheet sheet = wb.getSheet("Other"); sheet.shiftRows(12, 165, 12, false, true); wb.write(new FileOutputStream("unable_to_read_file.output.xls")); -- Please use the attached file for testing, thanks a lot!
Fixed in svn r741036 (and svn r741037 ) The example spreadsheet you supplied has incorrect values in RowRecord firstCol & lastCol. Excel has no problem with those values being wrong, except when no cells are present. POI wasn't properly updating these indexes the newly emptied row. This problem has been fixed and a junit has been added. Some extra confusion was noticed regarding cell comments (HSSFComment). It seems like the firstCol and lastCol fields of RowRecord need to take cell comments into account. POI does not do this yet. Some significant restructuring might be required to make that work properly.