Issue: Excel found unreadable content in "xxx.xlsx". Do you want to restore the contents of this workbook? Original

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.