You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Mary <Ma...@gmail.com> on 2011/01/20 20:00:20 UTC

Excel textbox objects

Is there a way to find all the text box objects in a worksheet?  (I need to get
the text from them)

I have .xls (office 2003 and below) as well as .xlsx files.  A little code
snippet would be helpful.  I'm getting lost in the documentation!



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Excel textbox objects

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
I had the chance to play with some HSSF stream code just a short while ago
and have to report partial success or partial faliure depending on how you
view it. It is possible to get at the Textboxes but when I tried to recover
their contents, all the getString() method recovered was an empty
HSSFRichTextString object.

Would not waste my time trying the approach I suggested Mary, sorry.

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Excel-textbox-objects-tp3350190p3351823.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Excel textbox objects

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Just had a quick look at the javadoc for the XSSF stream and it does not
appear that there is a similar method to allow you to get at an aggregate
record for the drawings in the sheet. The support should be there in the
openxml layer that underpins XSSF and this is proably the best place for you
to begin looking. One piece of advice that Nick usually gives is to create
two very simple workbooks, one with a textbox on it and one without. Next,
unzip both and see where the text box's information is stored and that
should point you to the data structure within the OOXML layer.

Yours

Mark B

PS Stil have not had time to test my previous suggestion re HSSF. If it
works, would you please post a confirmation to the list? Even if it does
not, would you still let us know please?
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Excel-textbox-objects-tp3350190p3351270.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Excel textbox objects

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Off of the top of my head, I think - and that is think - that I know how to
get at the text boxes on an HSSFSheet. You need to do the following;

1. Get the HSSFPatriarch object for the sheet.
2. On that object, call the getChildren() method to recover a list of
HSSFShapes that are on the sheet.
3. Iterate through that and check the type of each object, you are looking
for any HSSFTextbox instances.
4. If you find an HSSFTextbox, cast it to the correct type and then call the
getString() method to recover an HSSFRichTextString containing the objects
text.

Try that and see if it works, no promises though. The same code cannot be
used for the SpreadsheetML (xlsx) files sadly as they have quite a different
structure and you will need to dig around in the api to see if what you
require is even possible.

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Excel-textbox-objects-tp3350190p3350997.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org