Hi all, I am getting the follwoing Exception when I read attached Excel file uisng both POI-3.5-FINAL & POI-3.6. I had no problem to read it using POI-2.5 (please see test code at end of this mail).
Per POI change history, it seems previous fixed issue. In order to resolve the
issue, I hope that I don't have to create a beand new Excel file and copy data
over. Any advice is greatly appreciated.
Best regards,
Shui-chen
==== Exception ===========================
Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException:
Duplicate PageSettingsBlock record (sid=0x89c)
at
org.apache.poi.hssf.record.aggregates.PageSettingsBlock.checkNotPresent(PageSettingsBlock.java:227)
at
org.apache.poi.hssf.record.aggregates.PageSettingsBlock.readARecord(PageSettingsBlock.java:215)
at
org.apache.poi.hssf.record.aggregates.PageSettingsBlock.addLateRecords(PageSettingsBlock.java:639)
at org.apache.poi.hssf.model.Sheet.<init>(Sheet.java:222)
at org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:158)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:287)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:201)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:317)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:298)
at PoiTester.<init>(PoiTester.java:25)
at PoiTester.main(PoiTester.java:45)
/*======= test code ==============
======= also attached =========*/
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class PoiTester
{
private PoiTester() throws IOException
{
// Open
Workbook wb;
String filename = "C:\\poi\\wb_in.xls";
String fileout = "C:\\poi\\wb_out.xls";
if (filename.substring(filename.indexOf(".")+1).equalsIgnoreCase("xls"))
{
wb = new HSSFWorkbook(new FileInputStream(filename));
}
else {
wb = new XSSFWorkbook(new FileInputStream(filename));
}
// Save
if(wb instanceof XSSFWorkbook) {
fileout = fileout + "x";
}
// Close
FileOutputStream out = new FileOutputStream(fileout);
wb.write(out);
out.close();
}
public static void main(String[] args)
{
try {
new PoiTester();
} catch (IOException e) {
e.printStackTrace();
}
}
}
wb_in.xls
Description: MS-Excel spreadsheet
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
