Phenomenon:
Point "Yes (Y)"
The Error242440_02.xml file that is mentioned in the prompt message:
Problem Recurrence:
Packagepoi;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJava.io.OutputStream;ImportOrg.apache.poi.ss.usermodel.Cell;ImportOrg.apache.poi.ss.usermodel.Row;ImportOrg.apache.poi.ss.usermodel.Sheet;Importorg.apache.poi.ss.util.CellRangeAddress;ImportOrg.apache.poi.xssf.usermodel.XSSFWorkbook; Public classFoundunreadrecord { Public Static voidMain (string[] args)throwsIOException {intRowNum = 1; Createexcel_reference (RowNum); Createexcel_withtips (RowNum); RowNum= 0; Createexcel_reference (RowNum); Createexcel_withtips (RowNum); } Private Static voidCreateexcel_reference (intRowNum)throwsFileNotFoundException, IOException {String fileName= "Unreadrecordtips_reference" +rownum+ ". xlsx"; Xssfworkbook WB=NewXssfworkbook (); Sheet Sheet= Wb.createsheet ("Unreadrecordtips"); for(inti = 0; I <= rowNum; i++) {row row=Sheet.createrow (i); Cell Cell= Row.createcell (0); Cell.setcellvalue ("Test" +i); } write (FileName, WB); } Private Static voidCreateexcel_withtips (intRowNum)throwsFileNotFoundException, IOException {String fileName= "Unreadrecordtips" +rownum+ ". xlsx";; Xssfworkbook WB=NewXssfworkbook (); Sheet Sheet= Wb.createsheet ("Unreadrecordtips"); for(inti = 0; I <= rowNum; i++) {row row=Sheet.createrow (i); Cell Cell= Row.createcell (0); Cell.setcellvalue ("Test" +i); Sheet.addmergedregion (NewCellrangeaddress (0, rowNum, 0, 0)); } write (FileName, WB); } Private Static voidWrite (String fileName, Xssfworkbook WB)throwsFileNotFoundException, IOException {outputstream stream=NewFileOutputStream (fileName); Wb.write (stream); Stream.Close (); }}
Analysis and cause: Org.apache.poi.xssf.usermodel.XSSFWorkbook under Merge cell operation,
Cells involved in org.apache.poi.ss.util.CellRangeAddress.CellRangeAddress (int firstrow, int lastrow, int firstcol, int lastcol) , if you make more than one addmergedregion operation on any of these cells, the above prompt appears when the generated Excel opens. TIPS: (1) Org.apache.poi.hssf.usermodel.HSSFWorkbook.HSSFWorkbook () no this problem. This may be because Xssfworkbook is a addmergedregion operation based on the Ooxml (. xlsx) file Format (2) POI
Issue: Excel found unreadable content in "xxx.xlsx". Do you want to restore the contents of this workbook? Original