标签:
现象:
点"是(Y)"
提示信息中提到的error242440_02.xml文件:
问题重现:
package poi; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class FoundUnreadRecord { public static void main(String[] args) throws IOException { int rowNum = 1; createExcel_Reference(rowNum); createExcel_WithTips(rowNum); rowNum = 0; createExcel_Reference(rowNum); createExcel_WithTips(rowNum); } private static void createExcel_Reference(int rowNum) throws FileNotFoundException, IOException { String fileName = "UnreadRecordTips_Reference"+rowNum+".xlsx"; XSSFWorkbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("UnreadRecordTips"); for (int i = 0; i <= rowNum; i++) { Row row = sheet.createRow(i); Cell cell = row.createCell(0); cell.setCellValue("test" + i); } write(fileName, wb); } private static void createExcel_WithTips(int rowNum) throws FileNotFoundException, IOException { String fileName = "UnreadRecordTips"+rowNum+".xlsx";; XSSFWorkbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("UnreadRecordTips"); for (int i = 0; i <= rowNum; i++) { Row row = sheet.createRow(i); Cell cell = row.createCell(0); cell.setCellValue("test" + i); sheet.addMergedRegion(new CellRangeAddress(0, rowNum, 0, 0)); } write(fileName, wb); } private static void write(String fileName, XSSFWorkbook wb) throws FileNotFoundException, IOException { OutputStream stream = new FileOutputStream(fileName); wb.write(stream); stream.close(); } }
问题:Excel在“xxx.xlsx”中发现不可读取的内容。是否恢复此工作薄的内容?【原创】
标签:
原文地址:http://www.cnblogs.com/softidea/p/4212886.html