You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Alec Swan <al...@gmail.com> on 2011/09/27 17:50:41 UTC
Problems with accessing named ranges
Hello,
I have a named range defined as
OFFSET(Sheet1!$B:$B,1,,COUNT(Sheet1!$B:$B),). I followed the
documentation and accessed the range as follows:
Name aNamedCell = targetWb.getName("DynamicChartData");
AreaReference aref = new AreaReference(aNamedCell.getRefersToFormula());
However, the last line throws "IllegalArgumentException: References
passed to the AreaReference must be contiguous, use
generateContiguous(ref) if you have non-contiguous references", but
the range is contiguous!
Moreover, calling
AreaReference.generateContiguous(aNamedCell.getRefersToFormula())
throws "java.lang.IllegalArgumentException: Invalid Formula cell
reference: 'OFFSET(Sheet1!$B'"
What I am trying to do is define a named range on the first two
columns of the first sheet and then programmatically add data to the
first sheet and not break the range.
Thoughts?
Thanks,
Alec
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Problems with accessing named ranges
Posted by Nick Burch <ni...@alfresco.com>.
On Tue, 27 Sep 2011, Alec Swan wrote:
> I have a named range defined as
> OFFSET(Sheet1!$B:$B,1,,COUNT(Sheet1!$B:$B),). I followed the
> documentation and accessed the range as follows:
>
> Name aNamedCell = targetWb.getName("DynamicChartData");
> AreaReference aref = new AreaReference(aNamedCell.getRefersToFormula());
>
> However, the last line throws "IllegalArgumentException: References
> passed to the AreaReference must be contiguous, use
> generateContiguous(ref) if you have non-contiguous references", but
> the range is contiguous!
Are you able to step into that code in (say) the eclipse debugger, and
track down why it's deciding that isn't contiguous?
One slight "fun" issue is that the formula isn't stored as the text, it's
stored in a parsed form (PTG). We have to turn that back into text for
display, and you're tripping over the code that handles that
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org