You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by convoyer <sh...@gmail.com> on 2008/04/02 12:31:58 UTC
[Apache - HSLF] - How to update a TextBox's text
Hi
I have created a new ppt from a template. This new file have textboxes and
rectangles.
I want to update these contents dynamically.
The problem is:
1) How can I identify a particular control it is.(if there is 5 textboxes
and 5 rectangles then how I know it is a particular textbox)
2) How can I set text to a particular textbox .
Looking forward for reply/suggestions
Thanks and regards
smg
--
View this message in context: http://www.nabble.com/-Apache---HSLF----How-to-update-a-TextBox%27s-text-tp16446655p16446655.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[2]: [Apache - HSLF] - How to update a TextBox's text
Posted by Yegor Kozlov <ye...@dinom.ru>.
Read the javadocs.
> Hi
> Thanks for the quick reply.
> The first issue i solved with getting the text, as I have only textboxes and
> rectangles.
> The second issue:
> I have already gone through the link you have added.
> I can add a new text box by setting text to it.
> But suppose if I have a textbox with the text "Default String" and I want to
> update it to "Updated String", how it can be done??
TextBox shape = ...;
shape.getTextRun().setText("Updated String");
> Right now what I am doing is that I am retrieving the anchor of the textbox,
> then deletes that textbox and then creates a new textbox with my text and
> places it in the saved anchor. Is there any alternate way??
> Also if you can excuse my knowledge in POI-HSLF, can u please solve the
> following queries:
> 1) Can my textbox automatically adjust its size based on the size of the
> text.
shape.resizeToFitText()
> 2) In the image part, can I put an image's URL just like
> int imgType = ppt.addPicture(new
> File("http://www.thegreenhead.com/imgs/perpetual-motion-globe-2.jpg"),Picture.JPEG);
> However this is not working for me :-(
No, this method works only with files.
You need to retrieve the image data first;
Yegor
> Thank You
> Yegor Kozlov wrote:
>>
>>
>>
>>> Hi
>>> I have created a new ppt from a template. This new file have textboxes
>>> and
>>> rectangles.
>>> I want to update these contents dynamically.
>>
>>> The problem is:
>>> 1) How can I identify a particular control it is.(if there is 5 textboxes
>>> and 5 rectangles then how I know it is a particular textbox)
>>
>> It's up to you. For instance, you can identify them by the text value,
>> e.g. if it is
>> a TextBox and its value is "control1" then do something.
>>
>> You can identify your controls by position:
>>
>> java.awt.Rectangle anchor = shape.getAnchor(); //gets position in the
>> slide
>>
>> You can tag your controls with different colors: red, blue, ...
>>
>>> 2) How can I set text to a particular textbox .
>>
>> http://poi.apache.org/hslf/how-to-shapes.html
>>
>>
>> Yegor
>>
>>> Looking forward for reply/suggestions
>>
>>> Thanks and regards
>>> smg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: [Apache - HSLF] - How to update a TextBox's text
Posted by convoyer <sh...@gmail.com>.
Hi
Thanks for the quick reply.
The first issue i solved with getting the text, as I have only textboxes and
rectangles.
The second issue:
I have already gone through the link you have added.
I can add a new text box by setting text to it.
But suppose if I have a textbox with the text "Default String" and I want to
update it to "Updated String", how it can be done??
Right now what I am doing is that I am retrieving the anchor of the textbox,
then deletes that textbox and then creates a new textbox with my text and
places it in the saved anchor. Is there any alternate way??
Also if you can excuse my knowledge in POI-HSLF, can u please solve the
following queries:
1) Can my textbox automatically adjust its size based on the size of the
text.
2) In the image part, can I put an image's URL just like
int imgType = ppt.addPicture(new
File("http://www.thegreenhead.com/imgs/perpetual-motion-globe-2.jpg"),Picture.JPEG);
However this is not working for me :-(
Thank You
Yegor Kozlov wrote:
>
>
>
>> Hi
>> I have created a new ppt from a template. This new file have textboxes
>> and
>> rectangles.
>> I want to update these contents dynamically.
>
>> The problem is:
>> 1) How can I identify a particular control it is.(if there is 5 textboxes
>> and 5 rectangles then how I know it is a particular textbox)
>
> It's up to you. For instance, you can identify them by the text value,
> e.g. if it is
> a TextBox and its value is "control1" then do something.
>
> You can identify your controls by position:
>
> java.awt.Rectangle anchor = shape.getAnchor(); //gets position in the
> slide
>
> You can tag your controls with different colors: red, blue, ...
>
>> 2) How can I set text to a particular textbox .
>
> http://poi.apache.org/hslf/how-to-shapes.html
>
>
> Yegor
>
>> Looking forward for reply/suggestions
>
>> Thanks and regards
>> smg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/-Apache---HSLF----How-to-update-a-TextBox%27s-text-tp16446655p16467410.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: [Apache - HSLF] - How to update a TextBox's text
Posted by Yegor Kozlov <ye...@dinom.ru>.
> Hi
> I have created a new ppt from a template. This new file have textboxes and
> rectangles.
> I want to update these contents dynamically.
> The problem is:
> 1) How can I identify a particular control it is.(if there is 5 textboxes
> and 5 rectangles then how I know it is a particular textbox)
It's up to you. For instance, you can identify them by the text value, e.g. if it is
a TextBox and its value is "control1" then do something.
You can identify your controls by position:
java.awt.Rectangle anchor = shape.getAnchor(); //gets position in the slide
You can tag your controls with different colors: red, blue, ...
> 2) How can I set text to a particular textbox .
http://poi.apache.org/hslf/how-to-shapes.html
Yegor
> Looking forward for reply/suggestions
> Thanks and regards
> smg
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org