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/05/11 00:27:31 UTC

bugs with PageSettingsBlock - custom view

Dear list,

The POI version 3.6 claimed that several bugs associated with PageSettingsBlock have been fixed, but I am still having problem with PageSettingsBlock using the latest nightly build if the Excel file is having too many custom views (example attached).

Is there to resolve the problem in user level? Or will it be fixed soon in future release?

Many thanks!
Shuichen


==================================

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:37)
	at PoiTester.main(PoiTester.java:67)

--- 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 ****** 

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:\\poi\\wb_test.xls";
	   String fileout  = "C:\\poi\\wb_out.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();
	   }
   }
}