You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Danny Mui <da...@muibros.com> on 2003/01/02 18:31:06 UTC

Record Reordering - Print Areas

In struggling with Print Areas for the past few days, I finally figured 
out why the thing crashed on me.  Thank you guys for the hints on my 
first foray into BIFF records.

In the HSSFName class, the externsheet setting and indextoSheet stuff is 
encapsulated in the setSheetName method to protect the innocent in 
making excel files that dies a fiery death.  This is problematic when 
defining print areas because they are specific to an individual sheet. 
 I also found that this shielding yields global named regions no matter 
what sheetname is supplied.

So when I forced a sheet index into the correct offset, the spreadsheets 
would crash.

In order to match the excel generated files as best as possible, I had a 
hunch that the extern sheet definition and name region definition had a 
reference problem.  An Extern sheet record was defined before the bound 
sheet record was defined.

This is the file format that crashed Excel:

[SUPBOOK]
[EXTERNSHEET]
[NAMEs]
...fonts/styles/etc...
[USESELFS]
[BOUNDSHEETs]

I reordered the records such that it matched excel-generated files:

...fonts/styles/etc...
[USESELFS]
[BOUNDSHEETs]
[SUPBOOK]
[EXTERNSHEET]
[NAMEs]

After making this change, the unit tests are still ok and the Print 
Areas/Named regions work fine for their specific sheets.  If nobody has 
any objections, I'll clean up the code and send it up to Bugzilla.  It 
partially addresses Bug 14089 so I'll create a new one.

Thanks!

danny


Branch time...speak now or forever hold your peace

Posted by "Andrew C. Oliver" <ac...@apache.org>.
So not too long ago I posted a "gee why don't we branch"..  I'm not 
going to close the 1.5 branch yet as I think that warrants a vote,
but I'm going to go ahead and create the nextgen branch.

The only feedback I've gotten so far has been positive.  If you were 
biting your lip waiting for the right time to speak... its now.
Tomorrow will probably be too late....

-Andy



Re: Record Reordering - Print Areas

Posted by Avik Sengupta <av...@apache.org>.
Yep, the there are many range utils within HSSF , with a lot of overlap. Also,
many of the methods in the Range utils arent used at all. All this is indeed a
prime area for refactoring. 

Quoting Danny Mui <da...@muibros.com>:

> I agree with your assessment, I looked at the Range utilities and that 
> drove me batty.  I plan to add more unit tests and make it more reusable 
> (addresses more cleanly written).  The only risks I see with names can 
> be isolated in sheet indexing (afaik), so keeping that shielded should 
> alleviate that concern.  I guess that's a start.
> 
> Andrew C. Oliver wrote:
> 
> > No I just meant that the name code seems brittle and is not IMHO 
> > particularly well written.  I'd like to see it with unit tests, cleanly
> > written, less brittle, etc..  Which I suppose means rewritting it. 
> > -Andy
> >
> > Danny Mui wrote:
> >
> >> I had thoughts of adding name creation methods to the sheets for 
> >> sheet specific regions and restricting the workbook level names to 
> >> global named regions to simplify the API some (and not having to 
> >> write those pesky external reference formulas).
> >>
> >> But these thoughts don't constitute a rewrite.  What did you have in 
> >> mind?
> >>
> >>
> >> Andrew C. Oliver wrote:
> >>
> >>> Sounds reasonable.  I'd like to see names completely rewritten.
> >>>
> >>
> >>
> >>
> >> -- 
> >> To unsubscribe, e-mail:   
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail: 
> >> <ma...@jakarta.apache.org>
> >>
> >>
> >
> >
> >
> >
> > -- 
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



Re: Record Reordering - Print Areas

Posted by Avik Sengupta <av...@apache.org>.
Yep, the there are many range utils within HSSF , with a lot of overlap. Also,
many of the methods in the Range utils arent used at all. All this is indeed a
prime area for refactoring. 

Quoting Danny Mui <da...@muibros.com>:

> I agree with your assessment, I looked at the Range utilities and that 
> drove me batty.  I plan to add more unit tests and make it more reusable 
> (addresses more cleanly written).  The only risks I see with names can 
> be isolated in sheet indexing (afaik), so keeping that shielded should 
> alleviate that concern.  I guess that's a start.
> 
> Andrew C. Oliver wrote:
> 
> > No I just meant that the name code seems brittle and is not IMHO 
> > particularly well written.  I'd like to see it with unit tests, cleanly
> > written, less brittle, etc..  Which I suppose means rewritting it. 
> > -Andy
> >
> > Danny Mui wrote:
> >
> >> I had thoughts of adding name creation methods to the sheets for 
> >> sheet specific regions and restricting the workbook level names to 
> >> global named regions to simplify the API some (and not having to 
> >> write those pesky external reference formulas).
> >>
> >> But these thoughts don't constitute a rewrite.  What did you have in 
> >> mind?
> >>
> >>
> >> Andrew C. Oliver wrote:
> >>
> >>> Sounds reasonable.  I'd like to see names completely rewritten.
> >>>
> >>
> >>
> >>
> >> -- 
> >> To unsubscribe, e-mail:   
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail: 
> >> <ma...@jakarta.apache.org>
> >>
> >>
> >
> >
> >
> >
> > -- 
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



Re: Record Reordering - Print Areas

Posted by Avik Sengupta <av...@apache.org>.
Yep, the there are many range utils within HSSF , with a lot of overlap. Also,
many of the methods in the Range utils arent used at all. All this is indeed a
prime area for refactoring. 

Quoting Danny Mui <da...@muibros.com>:

> I agree with your assessment, I looked at the Range utilities and that 
> drove me batty.  I plan to add more unit tests and make it more reusable 
> (addresses more cleanly written).  The only risks I see with names can 
> be isolated in sheet indexing (afaik), so keeping that shielded should 
> alleviate that concern.  I guess that's a start.
> 
> Andrew C. Oliver wrote:
> 
> > No I just meant that the name code seems brittle and is not IMHO 
> > particularly well written.  I'd like to see it with unit tests, cleanly
> > written, less brittle, etc..  Which I suppose means rewritting it. 
> > -Andy
> >
> > Danny Mui wrote:
> >
> >> I had thoughts of adding name creation methods to the sheets for 
> >> sheet specific regions and restricting the workbook level names to 
> >> global named regions to simplify the API some (and not having to 
> >> write those pesky external reference formulas).
> >>
> >> But these thoughts don't constitute a rewrite.  What did you have in 
> >> mind?
> >>
> >>
> >> Andrew C. Oliver wrote:
> >>
> >>> Sounds reasonable.  I'd like to see names completely rewritten.
> >>>
> >>
> >>
> >>
> >> -- 
> >> To unsubscribe, e-mail:   
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail: 
> >> <ma...@jakarta.apache.org>
> >>
> >>
> >
> >
> >
> >
> > -- 
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



Re: Record Reordering - Print Areas

Posted by Avik Sengupta <av...@apache.org>.
Yep, the there are many range utils within HSSF , with a lot of overlap. Also,
many of the methods in the Range utils arent used at all. All this is indeed a
prime area for refactoring. 

Quoting Danny Mui <da...@muibros.com>:

> I agree with your assessment, I looked at the Range utilities and that 
> drove me batty.  I plan to add more unit tests and make it more reusable 
> (addresses more cleanly written).  The only risks I see with names can 
> be isolated in sheet indexing (afaik), so keeping that shielded should 
> alleviate that concern.  I guess that's a start.
> 
> Andrew C. Oliver wrote:
> 
> > No I just meant that the name code seems brittle and is not IMHO 
> > particularly well written.  I'd like to see it with unit tests, cleanly
> > written, less brittle, etc..  Which I suppose means rewritting it. 
> > -Andy
> >
> > Danny Mui wrote:
> >
> >> I had thoughts of adding name creation methods to the sheets for 
> >> sheet specific regions and restricting the workbook level names to 
> >> global named regions to simplify the API some (and not having to 
> >> write those pesky external reference formulas).
> >>
> >> But these thoughts don't constitute a rewrite.  What did you have in 
> >> mind?
> >>
> >>
> >> Andrew C. Oliver wrote:
> >>
> >>> Sounds reasonable.  I'd like to see names completely rewritten.
> >>>
> >>
> >>
> >>
> >> -- 
> >> To unsubscribe, e-mail:   
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail: 
> >> <ma...@jakarta.apache.org>
> >>
> >>
> >
> >
> >
> >
> > -- 
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



Re: Record Reordering - Print Areas

Posted by Danny Mui <da...@muibros.com>.
I agree with your assessment, I looked at the Range utilities and that 
drove me batty.  I plan to add more unit tests and make it more reusable 
(addresses more cleanly written).  The only risks I see with names can 
be isolated in sheet indexing (afaik), so keeping that shielded should 
alleviate that concern.  I guess that's a start.

Andrew C. Oliver wrote:

> No I just meant that the name code seems brittle and is not IMHO 
> particularly well written.  I'd like to see it with unit tests, cleanly
> written, less brittle, etc..  Which I suppose means rewritting it. 
> -Andy
>
> Danny Mui wrote:
>
>> I had thoughts of adding name creation methods to the sheets for 
>> sheet specific regions and restricting the workbook level names to 
>> global named regions to simplify the API some (and not having to 
>> write those pesky external reference formulas).
>>
>> But these thoughts don't constitute a rewrite.  What did you have in 
>> mind?
>>
>>
>> Andrew C. Oliver wrote:
>>
>>> Sounds reasonable.  I'd like to see names completely rewritten.
>>>
>>
>>
>>
>> -- 
>> To unsubscribe, e-mail:   
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail: 
>> <ma...@jakarta.apache.org>
>>
>>
>
>
>
>
> -- 
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>



Re: Record Reordering - Print Areas

Posted by "Andrew C. Oliver" <ac...@apache.org>.
No I just meant that the name code seems brittle and is not IMHO 
particularly well written.  I'd like to see it with unit tests, cleanly
written, less brittle, etc..  Which I suppose means rewritting it.  

-Andy

Danny Mui wrote:

> I had thoughts of adding name creation methods to the sheets for sheet 
> specific regions and restricting the workbook level names to global 
> named regions to simplify the API some (and not having to write those 
> pesky external reference formulas).
>
> But these thoughts don't constitute a rewrite.  What did you have in 
> mind?
>
>
> Andrew C. Oliver wrote:
>
>> Sounds reasonable.  I'd like to see names completely rewritten.
>>
>
>
>
> -- 
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>




Re: Record Reordering - Print Areas

Posted by Danny Mui <da...@muibros.com>.
I had thoughts of adding name creation methods to the sheets for sheet 
specific regions and restricting the workbook level names to global 
named regions to simplify the API some (and not having to write those 
pesky external reference formulas).

But these thoughts don't constitute a rewrite.  What did you have in mind?


Andrew C. Oliver wrote:

> Sounds reasonable.  I'd like to see names completely rewritten.
>



Re: Record Reordering - Print Areas

Posted by "Andrew C. Oliver" <ac...@apache.org>.
Sounds reasonable.  I'd like to see names completely rewritten.

Danny Mui wrote:

> In struggling with Print Areas for the past few days, I finally 
> figured out why the thing crashed on me.  Thank you guys for the hints 
> on my first foray into BIFF records.
>
> In the HSSFName class, the externsheet setting and indextoSheet stuff 
> is encapsulated in the setSheetName method to protect the innocent in 
> making excel files that dies a fiery death.  This is problematic when 
> defining print areas because they are specific to an individual sheet. 
> I also found that this shielding yields global named regions no matter 
> what sheetname is supplied.
>
> So when I forced a sheet index into the correct offset, the 
> spreadsheets would crash.
>
> In order to match the excel generated files as best as possible, I had 
> a hunch that the extern sheet definition and name region definition 
> had a reference problem.  An Extern sheet record was defined before 
> the bound sheet record was defined.
>
> This is the file format that crashed Excel:
>
> [SUPBOOK]
> [EXTERNSHEET]
> [NAMEs]
> ...fonts/styles/etc...
> [USESELFS]
> [BOUNDSHEETs]
>
> I reordered the records such that it matched excel-generated files:
>
> ...fonts/styles/etc...
> [USESELFS]
> [BOUNDSHEETs]
> [SUPBOOK]
> [EXTERNSHEET]
> [NAMEs]
>
> After making this change, the unit tests are still ok and the Print 
> Areas/Named regions work fine for their specific sheets.  If nobody 
> has any objections, I'll clean up the code and send it up to 
> Bugzilla.  It partially addresses Bug 14089 so I'll create a new one.
>
> Thanks!
>
> danny
>
>
> -- 
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>