https://issues.apache.org/bugzilla/show_bug.cgi?id=51601
Bug #: 51601
Summary: Excel 2003 and 2007 can not open file generated by poi
if the number of sheet in a workbook exceed 1370
sheets
Product: POI
Version: 3.7
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
Created attachment 27341
--> https://issues.apache.org/bugzilla/attachment.cgi?id=27341
Corrupted file created by poi 3.7, workbook with 1371 sheets
I use the version of POI(3.7) to create 1400 sheets in a workbook. And when I
open the XLS file generated by the programe, the MS excel 2003 pops the error
like bellow.
Damage to the file was so extensive that repairs were not possible. Excel
attempted to recover your formulas and values, but some data may have been
lost or corrupted.
In addition, if the number of sheet is under 1370, it can be opened normally.
Also when I use POI 2.5.1 the workbook is generated fine.
Attached is the generated file and here is the test code:
package com.test;
import java.io.FileOutputStream;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.DataFormat;
//import org.apache.poi.ss.util.Color;
//import org.apache.poi.ss.util.Region;
public class poiTest36 {
Workbook m_wb;
Font m_boldFont;
CellStyle cellStyle;
poiTest36() {
m_wb = new HSSFWorkbook();
m_boldFont = m_wb.createFont();
m_boldFont.setBoldweight( Font.BOLDWEIGHT_BOLD );
cellStyle=m_wb.createCellStyle();
}
public void createSheet(){
Sheet sheet=m_wb.createSheet();
cellStyle.setFont(m_boldFont);
cellStyle.setBorderBottom( CellStyle.BORDER_MEDIUM );
cellStyle.setBorderRight( CellStyle.BORDER_MEDIUM );
cellStyle.setBorderLeft( CellStyle.BORDER_MEDIUM);
cellStyle.setBorderTop( CellStyle.BORDER_MEDIUM);
Row row=sheet.createRow(1);
Cell cell=row.createCell((short)1);
cell.setCellStyle(cellStyle);
cell.setCellValue("Felix S");
}
public void save( String filename) throws Exception {
FileOutputStream fileout = new FileOutputStream( filename );
m_wb.write( fileout );
fileout.close();
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
poiTest36 p = new poiTest36();
for(int i=0; i<1371; i++) {
p.createSheet();
}
try {
p.save("/home/fsanchez/tmp/test.xls");
}
catch (Exception e){
System.out.println("got exeption:" + e.getMessage());
e.printStackTrace();
}
}
}
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]