You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/05/15 14:31:31 UTC

DO NOT REPLY [Bug 47199] New: two Page Settings Blocks

https://issues.apache.org/bugzilla/show_bug.cgi?id=47199

           Summary: two Page Settings Blocks
           Product: POI
           Version: 3.5-dev
          Platform: PC
               URL: http://www.nabble.com/user/UserProfile.jtp?user=139638
                    5
        OS/Version: Windows XP
            Status: NEW
          Severity: regression
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: kumar.naveen@in.ibm.com
                CC: kumar.naveen@in.ibm.com


Hi
I am getting the following error when trying to run the following test case in
TestExcelExtractor.java: 

public void testImportMacroPSB() throws Exception {
        String filename =
"C:\\poi-src-3.5-beta5-20090512\\poi-3.5-beta5\\testOLD\\test.xls";
        InputStream macro = new FileInputStream(filename);
        Workbook oldWb = new HSSFWorkbook(macro);
        assertNotNull(oldWb);
          FileOutputStream out = new FileOutputStream("c:/testPSB.xls");
          oldWb.write(out);
            out.close();

    }


Exception in thread "main" java.lang.RuntimeException: two Page Settings Blocks
found in the same sheet
    at org.apache.poi.hssf.model.Sheet.<init>(Sheet.java:241)
    at org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:160)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:288)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:202)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:318)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:299)
    at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:60)
    at
com.ericsson.ccrtool.excel.impl.write.ExcelSheetComparer.main(ExcelSheetComparer.java:29)

This is not similar to bug
https://issues.apache.org/bugzilla/show_bug.cgi?id=46840. Here the exception is
coming in line number 241 of Sheet.java

The test file I am using here is an old file (1 year old ), When I open the
file and change some cell value then the test case is passed. But I dont want
to open and save all the file each time when ever I am getting the above error. 


I have also run the the POI code BiffViewer.java for both the old file (Which
is giving problem) and the new file (open the old file save the file make new
file) and I found that there is difference in the TABID element of the output
file. In the correct file the element_0 start with counter "1" which was "O" in
the old file.

old file(PSB problem file)

[TABID]
    .elements        = 17
    .element_0 = 0
    .element_1 = 1
    .element_2 = 2
    .element_3 = 3
    .element_4 = 4
    .element_5 = 5
    .element_6 = 6
    .element_7 = 7
    .element_8 = 8
    .element_9 = 9
    .element_10 = 10
    .element_11 = 11
    .element_12 = 12
    .element_13 = 13
    .element_14 = 14
    .element_15 = 15
    .element_16 = 16
[/TABID]


New file (open and save the old file)
[TABID]
    .elements        = 17
    .element_0 = 1
    .element_1 = 2
    .element_2 = 3
    .element_3 = 4
    .element_4 = 5
    .element_5 = 6
    .element_6 = 7
    .element_7 = 8
    .element_8 = 9
    .element_9 = 10
    .element_10 = 11
    .element_11 = 12
    .element_12 = 13
    .element_13 = 14
    .element_14 = 15
    .element_15 = 16
    .element_16 = 17
[/TABID]

I am sorry to say that I cant share my test file as per company privacy rule. 

Please let me know if you could help me on this issue. 

This problem is coming with both Excel 2003 file and Excel 2007 file and I have
taken the latest (14 May 2009) zip file from the POI 3.5 

Waiting for your reply.. 

Thanks and Regards 
Naveen Kumar

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Naveen <ku...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW
           Severity|regression                  |critical




--- Comment #11 from Naveen <ku...@in.ibm.com>  2009-05-28 00:28:56 PST ---
Hi

Please let  me know if any one is working on this.. 

Waiting for your reply . 

Thanks 
Naveen

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Naveen <ku...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW
         AssignedTo|dev@poi.apache.org          |kumar.naveen@in.ibm.com




--- Comment #5 from Naveen <ku...@in.ibm.com>  2009-05-19 06:11:07 PST ---
Created an attachment (id=23688)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23688)
new output file without PSB problem

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Naveen <ku...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |




--- Comment #2 from Naveen <ku...@in.ibm.com>  2009-05-18 00:28:49 PST ---
Hi, 

Sorry, the error is coming in line number 236 now. I have taken the latest jar
files: 
poi-contrib-3.5-beta6-20090518.jar
poi-ooxml-3.5-beta6-20090518.jar
poi-scratchpad-3.5-beta6-20090518.jar
poi-3.5-beta6-20090518.jar

Following exception is throwing in the console. 

Exception in thread "main" java.lang.RuntimeException: two Page Settings Blocks
found in the same sheet
    at org.apache.poi.hssf.model.Sheet.<init>(Sheet.java:236)
    at org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:162)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:288)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:202)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:318)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:299)
    at
org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:60). 

This is coming with my old file also. The step to recreate is same as above.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




--- Comment #1 from Josh Micich <jo...@gildedtree.com>  2009-05-15 11:11:48 PST ---
Another bug besides bug 46840 was fixed recently: bug 46953.  That fix was made
on May 11, and if you were running that code, it would be impossible to get
that exception from line 241.  In the most recent version of Sheet.java (since
May 11) this exception would have been thrown from line 236: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/Sheet.java?annotate=773438

The top pair of frames in your stacktrace is matched by revisions 757520 to
773411 (Mar 23 bug 46840 - May 11 bug 46953)
I am closing this bug on the assumption that that you're running a slightly
older version of POI than May 14.  If you experience a similar problem please
re-open with the new details.

Nightly builds can be found here http://encore.torchbox.com/poi-svn-build/
The fix for bug 46953 found from this file: poi-source-3.5-beta6-20090511.zip
onwards.


Thanks for doing the extra investigation using BiffViewer.  I am guessing that
the changes Excel made to the TABIDs  is unrelated to your problem.

Hopefully you don't need to troubleshoot further, but if Excel 'fixed' the file
for your problem, it's likely that it shuffled a few records around, and that
information would be interesting.  If you pipe the BiffViewer output through
"grep Offset=0x", that will extract only the record headers.  The resulting
file will not have any proprietary data, but the ordering of biff records will
be preserved and that would be enough to diagnose this bug.

*** This bug has been marked as a duplicate of bug 46953 ***

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199





--- Comment #15 from Naveen <ku...@in.ibm.com>  2009-06-02 04:39:21 PST ---
Thanks a lot for the solution. 

Cheers!!!
Naveen

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEEDINFO




--- Comment #3 from Josh Micich <jo...@gildedtree.com>  2009-05-18 10:09:02 PST ---
Thanks for re-verifying the bug with the most recent POI build.

In general it is difficult to fix any problem without sample the code/data to
reproduce it.  Can you please upload the BiffViewer summary as mentioned above
(pipe the BiffViewer output through "grep Offset=0x").  It will help to have
BIFF summaries for both files (the '1 year old' file and the one re-saved by
Excel).

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




--- Comment #7 from Josh Micich <jo...@gildedtree.com>  2009-05-21 12:51:13 PST ---
The files you uploaded are incomplete.  It appears that the output of BiffView
has been truncated.  None of the sheet sub-streams are present, and even the
workbook stream is incomplete.  I can see 49 BOUNDSHEET records which implies
49 sheet sub-streams are missing.

I am pretty sure that BiffView will not silently quit in the middle of a file.
So either it crashed and you didn't mention that, or you have deliberately
truncated the output hoping that we only needed to consider the record order in
the first 5% of the workbook.  Perhaps you are concerned that even these BIFF
header summaries constitute information that you must keep private.  I can't
convince you otherwise, but at least let us know that's what you are thinking.


If you are not able to upload a complete BIFF summary, you could try single
stepping the code in a debugger:
 - First (since there are many sheets), find out which sheet the error occurs
on.  When the bug occurs, take at "this._sheets.size" 2 stack frames up
(HSSFWorkbook.java:288). 
 - Next re-run your app and progress over all the previous sheets and stop at
HSSFWorkbook.java:288 before reading the sheet with the problem.
 - Put a breakpoint on line Sheet.java:219, let the app execute to there.
 - Observe carefully how many and which records are read from the RecordStream
in the PageSettingsBlock constructor.
 - Let the app run to the Sheet.java:219 breakpoint again.  Pay attention to
which records (non-PSB) have been read from the RecordStream since creating the
PageSettingsBlock, and the current record (which seems to belong to the PSB)
 - Make sure that execution _immediately_ proceeds to the exception at
Sheet.java:236 (otherwise you haven't observed the exact conditions for the bug
yet)

When you find out specifically what POI is doing wrong (and what Excel is doing
'right'), please reply here so we can incorporate this knowledge back into POI.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199





--- Comment #13 from Naveen <ku...@in.ibm.com>  2009-05-31 22:15:44 PST ---
Hi Chris,

Thanks for your repley . 

I dont know how to use the event model and all. 

Please suggest me how to resolve the error, as my release is pending due to
this error. 

Thanks
Naveen

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #9 from Josh Micich <jo...@gildedtree.com>  2009-05-22 11:07:16 PST ---
It seems like you are going with the debugging approach.

(In reply to comment #8)
> How do I get the sheet name? I have searched in the code but not able to get
> the sheet.

At stack frame (HSSFWorkbook.java:288), you can see the number of already
loaded sheets with "_sheets.size()".  This also happens to be the index to the
sheet currently being constructed, so that sheet name can be observed with:
workbook.getSheetName(_sheets.size());


> In Sheet.java :
> I have tried to print the "recSid" the value is coming as 41 (Dec) and 0x0029
> (hex).

That sid corresponds to BottomMarginRecord.  We are going to need more
information than this (see Comment 7).  Basically we need the list of records
(found within RecordStream rs) starting from the records that the _psBlock has,
all the way through to the current record (seems to be BottomMarginRecord) and
a little further, just to make sure there are no more PSB records after that. 
I guess that execution was at line 234 when you made this observation.  That's
an important detail to clarify too.


> the value for " _psBlock != records.get(prevPsbIx) " is coming as true in my
> case, Is it correct or we have to use equals method for comparing the objects.

Did you try out your suggestion "!_psBlock.equals(records.get(prevPsbIx))"?

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Naveen <ku...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |




-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199





--- Comment #12 from Chris Lott <ap...@chris-lott.org>  2009-05-28 11:48:57 PST ---
I hit this problem today on a XLS (Excel 2003) file when reading it with HSSF
from POI 3.5 beta 5 of Feb 19, 2009.  I too am working with proprietary data
that I cannot upload, and I bet that any modification will cause the problem to
vanish.  The one bright spot: I tried reading the file with the streaming HSSF
approach (i.e., eventusermodel, HSSFListener, and friends), and that worked
very well.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199





--- Comment #10 from Naveen <ku...@in.ibm.com>  2009-05-25 02:33:00 PST ---
Created an attachment (id=23710)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23710)
Giving PSB problem 


I have attached the file which is giving PSB problem. 

Please use this file directly, if you open and change any of the value then
this wont throw exception.



Test Case :
================


    public void testImportMacroPSB() throws Exception {
        String filename =
"C:\\poi-src-3.5-beta5-20090219\\poi-3.5-beta5\\testOLD\\excel.xls";
        InputStream macro = new FileInputStream(filename);
        Workbook oldWb = new HSSFWorkbook(macro);
        assertNotNull(oldWb);
          FileOutputStream out = new FileOutputStream("c:/testPSB.xls");
          oldWb.write(out);
            out.close();
    }


Please let me you if anything else is required. 

Thanks 
Naveen Kumar

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #14 from Josh Micich <jo...@gildedtree.com>  2009-06-01 11:53:53 PST ---
Fixed in svn r780774 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=780774 )

junits added

Thanks for taking the time to upload something that would reproduce the error. 
The problem in the sample file (attachment id=23710) was that the margin
records are not found with the rest of the PageSettingsBlock.  If Excel
re-saves the file, it corrects that problem.  POI now does the same.

I'm not sure if if is of concern to you, but my Excel (2007) reports the data
loss in the sample file ("Shared workbook revisions and custom workbook views
may have been lost"). Same warning message from Excel after re-writing with
POI.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Naveen <ku...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|kumar.naveen@in.ibm.com     |dev@poi.apache.org




-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199


Naveen <ku...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW




--- Comment #8 from Naveen <ku...@in.ibm.com>  2009-05-22 03:41:06 PST ---
Hi, 

How do I get the sheet name? I have searched in the code but not able to get
the sheet.

In Sheet.java : 
I have tried to print the "recSid" the value is coming as 41 (Dec) and 0x0029
(hex).

the value for " _psBlock != records.get(prevPsbIx) " is coming as true in my
case, Is it correct or we have to use equals method for comparing the objects.
Please advise.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 47199] two Page Settings Blocks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47199





--- Comment #4 from Naveen <ku...@in.ibm.com>  2009-05-19 05:57:38 PST ---
Created an attachment (id=23687)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23687)
utput file which is giving PSB problem

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org