You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Shuichen Zhang <zh...@yahoo.com> on 2010/04/08 08:27:19 UTC
New Exception on Duplicate PageSettingsBlock record - custom view
Dear Dave,
After a few more testing, I encountered a new PageSettingsBlock exception, too many custom views within the Excel file (please see attached example), perhpas this is a new one that has not been fixed yet, could you please advise?
Thanks again!
Best regards,
Shui-Chen
/* =======================================================================
New Exception:
Exception in thread "main" java.lang.IllegalStateException: Found more than one PageSettingsBlock in custom view settings sub-stream
at org.apache.poi.hssf.record.aggregates.CustomViewSettingsRecordAggregate.<init>(CustomViewSettingsRecordAggregate.java:51)
at org.apache.poi.hssf.model.InternalSheet.<init>(InternalSheet.java:215)
at org.apache.poi.hssf.model.InternalSheet.createSheet(InternalSheet.java:162)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:289)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:203)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:319)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:300)
at PoiTester.<init>(PoiTester.java:40)
at PoiTester.main(PoiTester.java:70)
=====================================================================*/
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.Cell;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
public class PoiTester
{
private PoiTester() throws IOException
{
// Open
String filename = "C:\\java\\x_test\\wb2.xls";
String fileout = "C:\\java\\x_test\\wb2.xls";
Workbook wb = new HSSFWorkbook(new FileInputStream(filename));
CreationHelper createHelper = wb.getCreationHelper();
// do something
Sheet s = wb.getSheet("Sheet1");
Row r = null;
Cell c = null;
for(int rownum = 0; rownum < 30; rownum++) {
r = s.createRow(rownum);
for(int cellnum = 0; cellnum < 10; cellnum += 2) {
c = r.createCell(cellnum);
Cell c2 = r.createCell(cellnum+1);
c.setCellValue((double)rownum + (cellnum/10));
c2.setCellValue(
createHelper.createRichTextString("Hello! " + cellnum)
);
}
}
// Save & 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();
}
}
}
--- On Wed, 4/7/10, Shuichen Zhang <zh...@yahoo.com> wrote:
> From: Shuichen Zhang <zh...@yahoo.com>
> Subject: Re: POI-3.5 Exception on Duplicate PageSettingsBlock record
> To: "POI Users List" <us...@poi.apache.org>
> Date: Wednesday, April 7, 2010, 11:43 PM
> Dear Dave,
>
> As you suggested, I tried the latest nightly build, it
> resolved the PageSettingsBlock problem.
>
> Thank you so much for your help!
>
> Best regards,
> Shui-Chen
>
> --- On Wed, 4/7/10, David Fisher <df...@jmlafferty.com>
> wrote:
>
> > From: David Fisher <df...@jmlafferty.com>
> > Subject: Re: POI-3.5 Exception on Duplicate
> PageSettingsBlock record
> > To: "POI Users List" <us...@poi.apache.org>
> > Date: Wednesday, April 7, 2010, 6:45 PM
> > Several bugs with PageSettingsBlock
> > were resolved between 3.5 and 3.6, but then, if I
> recall
> > correctly, more were fixed since 3.6.
> >
> > I would suggest that you download the trunk and build
> from
> > source, or try a nightly build at http://encore.torchbox.com/poi-cvs-build/
> >
> > Regards,
> > Dave
> >
> > On Apr 7, 2010, at 3:34 PM, Shuichen Zhang wrote:
> >
> > > Dear POI user list:
> > >
> > > I cannot open attached Excl file using POI-3.5, I
> got
> > an exception on "Duplicate PageSettingsBlock record",
> could
> > anyone please help? Thank you in advance!
> > >
> > > Best regards,
> > > Shui-Chen
> > >
> > > // **** test code ******
> > > /*
> >
> =======================================================================
> > > Problem : POI-2.5
> > can open the Excel workbook,
> > >
> > but both POI-3.5_FINAL & POI-3.6 failed.
> > >
> > > 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:41)
> > > at
> > PoiTester.main(PoiTester.java:52)
> > >
> > >
> >
> =================================================================*/
> > >
> > > 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;
> > >
> > > public class PoiTester
> > > {
> > >
> > > private PoiTester() throws
> > IOException
> > > {
> > > // Open
> > > String filename =
> > "C:\\poi\\wb.xls";
> > > String
> > fileout = "C:\\poi\\wb_out.xls";
> > >
> > > Workbook wb = new
> > HSSFWorkbook(new FileInputStream(filename));
> > >
> > > // Save &
> > 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.xls>
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > > For additional commands, e-mail: user-help@poi.apache.org
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> > For additional commands, e-mail: user-help@poi.apache.org
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>