You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Hayato Iriumi <hi...@gmail.com> on 2015/05/13 08:25:46 UTC

Getting all ContentControls

Hello,

I'm trying to get a list of ContentControls in a word document. I've got an
instance of XWPFDocument, but getBodyElements or getBodyElementsIterator
only gives me back the first level of the document elements. The Content
Controls I have are children to the tables in the document.

I was looking for a convenient method that returns me all the document
elements, but I have not been able to find one. Should I write my own code
to give me all the elements in a word document or does POI already have
something like this?

RE: Getting all ContentControls

Posted by "Allison, Timothy B." <ta...@mitre.org>.
Hi Dominik,
  I personally don't have plans to add write capabilities.  Unfortunately, I don't have any justification at my day job to do this, and I don't have time outside of that to work on this.  Sorry.
  There may be others on this list, though, who would be interested in contributing that portion.  
  I've found the beans fairly easy to work with, and you may start there.  If you need a hook to get to the underlying beans, let me know, and I'll be more than happy to add that.

        Best,

                 Tim

-----Original Message-----
From: dominik_k [mailto:dominik.krichbaum@capgemini.com] 
Sent: Friday, February 3, 2017 3:44 AM
To: user@poi.apache.org
Subject: RE: Getting all ContentControls

Hi Tim!

I'm afraid, the implementation is still read-only. Are there any plans giving it write capabilities in the future? Else, is there any approach to set data (text) to CONTENTCONTROL-fields via Apache POI? For example: I'd like to use Apache POI for processing docx-template, where CONTENTCONTROL-fields exist for addresses, dates, .... . Here, I am examining the capability of POI to fill these fields with relevant data.

Cheers, Dominik :)


Allison, Timothy B. wrote
> Y, sorry.  The initial implementation is read-only.  A patch would be 
> welcome for write capability.
> 
> When I wrote the read-only code, I wrote wrappers around the 
> underlying xml beans...you'd want to do this as well.  You might look 
> at other write capabilities as models.
> 
> Beware: this would not be a trivial addition, but I'm sure that the 
> capability would be welcomed into the project!
> 
> Best,
> 
>                Tim
> 
> -----Original Message-----
> From: Hayato Iriumi [mailto:

> hiriumi@

> ]
> Sent: Friday, May 15, 2015 4:02 AM
> To: POI Users List
> Subject: Re: Getting all ContentControls
> 
> Hello,
> 
> Now that I got a content control (XWPFSDT), I want to set a text to 
> it. I looked through the source code but there doesn't seem to be an 
> implementation to modify the text. Am I missing something or this is 
> just not possible with POI at the moment? If this could be a new 
> feature that could be added, how would I go about doing it? I'm able 
> to compile POI on my machine now, so I am willing to take a shot.
> 
> 2015-05-14 5:31 GMT-07:00 Allison, Timothy B. &lt;

> tallison@

> &gt;:
> 
>> Great.  Thank you for letting me know that that solved your problem.  
>> I'm a bit hesitant to add that to XWPFDocument because it strips the 
>> SDTs of their context.  If the community thinks we should add it to 
>> XWPFDocument, though, I'm not strongly against it.
>>
>> Thank you again, and happy SDT processing!
>>
>> Best,
>>
>>           Tim
>>
>> -----Original Message-----
>> From: Hayato Iriumi [mailto:

> hiriumi@

> ]
>> Sent: Thursday, May 14, 2015 1:38 AM
>> To: POI Users List
>> Subject: Re: Getting all ContentControls
>>
>> Timothy,
>>
>> Thank you very much for your help! I was able to use the sample code 
>> (test code rather) and get the result I wanted. I guess 
>> extractAllSDTs in TestXWPFSDT.java could be implemented in 
>> XWPFDocument.java in the future, right?
>>
>> Again, thank you very much for your help! :)
>>
>>
>> 2015-05-13 10:42 GMT-07:00 Allison, Timothy B. &lt;

> tallison@

> &gt;:
>>
>> > Because content controls can be recursive and can be held within
>> recursive
>> > structures, you have to recurse to get all of them.
>> >
>> > You might want to take a look at
>> > org.apache.poi.xwpf.usermodel.TestXWPFSDT's extractAllSDTs(XWPFDoc) 
>> > as
>> a
>> > model.
>> >
>> >
>> > -----Original Message-----
>> > From: Hayato Iriumi [mailto:

> hiriumi@

> ]
>> > Sent: Wednesday, May 13, 2015 2:26 AM
>> > To: 

> user@.apache

>> > Subject: Getting all ContentControls
>> >
>> > Hello,
>> >
>> > I'm trying to get a list of ContentControls in a word document. 
>> > I've
>> got
>> an
>> > instance of XWPFDocument, but getBodyElements or
>> getBodyElementsIterator
>> > only gives me back the first level of the document elements. The
>> Content
>> > Controls I have are children to the tables in the document.
>> >
>> > I was looking for a convenient method that returns me all the 
>> > document elements, but I have not been able to find one. Should I 
>> > write my own
>> code
>> > to give me all the elements in a word document or does POI already 
>> > have something like this?
>> >
>> > -------------------------------------------------------------------
>> > --
>> > To unsubscribe, e-mail: 

> user-unsubscribe@.apache

>> > For additional commands, e-mail: 

> user-help@.apache

>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: 

> user-unsubscribe@.apache

>> For additional commands, e-mail: 

> user-help@.apache

>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 

> user-unsubscribe@.apache

> For additional commands, e-mail: 

> user-help@.apache





--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Getting-all-ContentControls-tp5718805p5726470.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


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


RE: Getting all ContentControls

Posted by dominik_k <do...@capgemini.com>.
Hi Tim!

I'm afraid, the implementation is still read-only. Are there any plans
giving it write capabilities in the future? Else, is there any approach to
set data (text) to CONTENTCONTROL-fields via Apache POI? For example: I'd
like to use Apache POI for processing docx-template, where
CONTENTCONTROL-fields exist for addresses, dates, .... . Here, I am
examining the capability of POI to fill these fields with relevant data.

Cheers, Dominik :)


Allison, Timothy B. wrote
> Y, sorry.  The initial implementation is read-only.  A patch would be
> welcome for write capability.
> 
> When I wrote the read-only code, I wrote wrappers around the underlying
> xml beans...you'd want to do this as well.  You might look at other write
> capabilities as models.
> 
> Beware: this would not be a trivial addition, but I'm sure that the
> capability would be welcomed into the project!
> 
> Best,
> 
>                Tim
> 
> -----Original Message-----
> From: Hayato Iriumi [mailto:

> hiriumi@

> ] 
> Sent: Friday, May 15, 2015 4:02 AM
> To: POI Users List
> Subject: Re: Getting all ContentControls
> 
> Hello,
> 
> Now that I got a content control (XWPFSDT), I want to set a text to it. I
> looked through the source code but there doesn't seem to be an
> implementation to modify the text. Am I missing something or this is just
> not possible with POI at the moment? If this could be a new feature that
> could be added, how would I go about doing it? I'm able to compile POI on
> my machine now, so I am willing to take a shot.
> 
> 2015-05-14 5:31 GMT-07:00 Allison, Timothy B. &lt;

> tallison@

> &gt;:
> 
>> Great.  Thank you for letting me know that that solved your problem.  I'm
>> a bit hesitant to add that to XWPFDocument because it strips the SDTs of
>> their context.  If the community thinks we should add it to XWPFDocument,
>> though, I'm not strongly against it.
>>
>> Thank you again, and happy SDT processing!
>>
>> Best,
>>
>>           Tim
>>
>> -----Original Message-----
>> From: Hayato Iriumi [mailto:

> hiriumi@

> ]
>> Sent: Thursday, May 14, 2015 1:38 AM
>> To: POI Users List
>> Subject: Re: Getting all ContentControls
>>
>> Timothy,
>>
>> Thank you very much for your help! I was able to use the sample code
>> (test
>> code rather) and get the result I wanted. I guess extractAllSDTs in
>> TestXWPFSDT.java could be implemented in XWPFDocument.java in the future,
>> right?
>>
>> Again, thank you very much for your help! :)
>>
>>
>> 2015-05-13 10:42 GMT-07:00 Allison, Timothy B. &lt;

> tallison@

> &gt;:
>>
>> > Because content controls can be recursive and can be held within
>> recursive
>> > structures, you have to recurse to get all of them.
>> >
>> > You might want to take a look at
>> > org.apache.poi.xwpf.usermodel.TestXWPFSDT's extractAllSDTs(XWPFDoc) as
>> a
>> > model.
>> >
>> >
>> > -----Original Message-----
>> > From: Hayato Iriumi [mailto:

> hiriumi@

> ]
>> > Sent: Wednesday, May 13, 2015 2:26 AM
>> > To: 

> user@.apache

>> > Subject: Getting all ContentControls
>> >
>> > Hello,
>> >
>> > I'm trying to get a list of ContentControls in a word document. I've
>> got
>> an
>> > instance of XWPFDocument, but getBodyElements or
>> getBodyElementsIterator
>> > only gives me back the first level of the document elements. The
>> Content
>> > Controls I have are children to the tables in the document.
>> >
>> > I was looking for a convenient method that returns me all the document
>> > elements, but I have not been able to find one. Should I write my own
>> code
>> > to give me all the elements in a word document or does POI already have
>> > something like this?
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: 

> user-unsubscribe@.apache

>> > For additional commands, e-mail: 

> user-help@.apache

>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: 

> user-unsubscribe@.apache

>> For additional commands, e-mail: 

> user-help@.apache

>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 

> user-unsubscribe@.apache

> For additional commands, e-mail: 

> user-help@.apache





--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Getting-all-ContentControls-tp5718805p5726470.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: Getting all ContentControls

Posted by "Allison, Timothy B." <ta...@mitre.org>.
Y, sorry.  The initial implementation is read-only.  A patch would be welcome for write capability.

When I wrote the read-only code, I wrote wrappers around the underlying xml beans...you'd want to do this as well.  You might look at other write capabilities as models.

Beware: this would not be a trivial addition, but I'm sure that the capability would be welcomed into the project!

Best,

               Tim

-----Original Message-----
From: Hayato Iriumi [mailto:hiriumi@gmail.com] 
Sent: Friday, May 15, 2015 4:02 AM
To: POI Users List
Subject: Re: Getting all ContentControls

Hello,

Now that I got a content control (XWPFSDT), I want to set a text to it. I
looked through the source code but there doesn't seem to be an
implementation to modify the text. Am I missing something or this is just
not possible with POI at the moment? If this could be a new feature that
could be added, how would I go about doing it? I'm able to compile POI on
my machine now, so I am willing to take a shot.

2015-05-14 5:31 GMT-07:00 Allison, Timothy B. <ta...@mitre.org>:

> Great.  Thank you for letting me know that that solved your problem.  I'm
> a bit hesitant to add that to XWPFDocument because it strips the SDTs of
> their context.  If the community thinks we should add it to XWPFDocument,
> though, I'm not strongly against it.
>
> Thank you again, and happy SDT processing!
>
> Best,
>
>           Tim
>
> -----Original Message-----
> From: Hayato Iriumi [mailto:hiriumi@gmail.com]
> Sent: Thursday, May 14, 2015 1:38 AM
> To: POI Users List
> Subject: Re: Getting all ContentControls
>
> Timothy,
>
> Thank you very much for your help! I was able to use the sample code (test
> code rather) and get the result I wanted. I guess extractAllSDTs in
> TestXWPFSDT.java could be implemented in XWPFDocument.java in the future,
> right?
>
> Again, thank you very much for your help! :)
>
>
> 2015-05-13 10:42 GMT-07:00 Allison, Timothy B. <ta...@mitre.org>:
>
> > Because content controls can be recursive and can be held within
> recursive
> > structures, you have to recurse to get all of them.
> >
> > You might want to take a look at
> > org.apache.poi.xwpf.usermodel.TestXWPFSDT's extractAllSDTs(XWPFDoc) as a
> > model.
> >
> >
> > -----Original Message-----
> > From: Hayato Iriumi [mailto:hiriumi@gmail.com]
> > Sent: Wednesday, May 13, 2015 2:26 AM
> > To: user@poi.apache.org
> > Subject: Getting all ContentControls
> >
> > Hello,
> >
> > I'm trying to get a list of ContentControls in a word document. I've got
> an
> > instance of XWPFDocument, but getBodyElements or getBodyElementsIterator
> > only gives me back the first level of the document elements. The Content
> > Controls I have are children to the tables in the document.
> >
> > I was looking for a convenient method that returns me all the document
> > elements, but I have not been able to find one. Should I write my own
> code
> > to give me all the elements in a word document or does POI already have
> > something like this?
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: Getting all ContentControls

Posted by Hayato Iriumi <hi...@gmail.com>.
Hello,

Now that I got a content control (XWPFSDT), I want to set a text to it. I
looked through the source code but there doesn't seem to be an
implementation to modify the text. Am I missing something or this is just
not possible with POI at the moment? If this could be a new feature that
could be added, how would I go about doing it? I'm able to compile POI on
my machine now, so I am willing to take a shot.

2015-05-14 5:31 GMT-07:00 Allison, Timothy B. <ta...@mitre.org>:

> Great.  Thank you for letting me know that that solved your problem.  I'm
> a bit hesitant to add that to XWPFDocument because it strips the SDTs of
> their context.  If the community thinks we should add it to XWPFDocument,
> though, I'm not strongly against it.
>
> Thank you again, and happy SDT processing!
>
> Best,
>
>           Tim
>
> -----Original Message-----
> From: Hayato Iriumi [mailto:hiriumi@gmail.com]
> Sent: Thursday, May 14, 2015 1:38 AM
> To: POI Users List
> Subject: Re: Getting all ContentControls
>
> Timothy,
>
> Thank you very much for your help! I was able to use the sample code (test
> code rather) and get the result I wanted. I guess extractAllSDTs in
> TestXWPFSDT.java could be implemented in XWPFDocument.java in the future,
> right?
>
> Again, thank you very much for your help! :)
>
>
> 2015-05-13 10:42 GMT-07:00 Allison, Timothy B. <ta...@mitre.org>:
>
> > Because content controls can be recursive and can be held within
> recursive
> > structures, you have to recurse to get all of them.
> >
> > You might want to take a look at
> > org.apache.poi.xwpf.usermodel.TestXWPFSDT's extractAllSDTs(XWPFDoc) as a
> > model.
> >
> >
> > -----Original Message-----
> > From: Hayato Iriumi [mailto:hiriumi@gmail.com]
> > Sent: Wednesday, May 13, 2015 2:26 AM
> > To: user@poi.apache.org
> > Subject: Getting all ContentControls
> >
> > Hello,
> >
> > I'm trying to get a list of ContentControls in a word document. I've got
> an
> > instance of XWPFDocument, but getBodyElements or getBodyElementsIterator
> > only gives me back the first level of the document elements. The Content
> > Controls I have are children to the tables in the document.
> >
> > I was looking for a convenient method that returns me all the document
> > elements, but I have not been able to find one. Should I write my own
> code
> > to give me all the elements in a word document or does POI already have
> > something like this?
> >
> > ---------------------------------------------------------------------
> > 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: Getting all ContentControls

Posted by "Allison, Timothy B." <ta...@mitre.org>.
Great.  Thank you for letting me know that that solved your problem.  I'm a bit hesitant to add that to XWPFDocument because it strips the SDTs of their context.  If the community thinks we should add it to XWPFDocument, though, I'm not strongly against it.

Thank you again, and happy SDT processing!

Best,

          Tim

-----Original Message-----
From: Hayato Iriumi [mailto:hiriumi@gmail.com] 
Sent: Thursday, May 14, 2015 1:38 AM
To: POI Users List
Subject: Re: Getting all ContentControls

Timothy,

Thank you very much for your help! I was able to use the sample code (test
code rather) and get the result I wanted. I guess extractAllSDTs in
TestXWPFSDT.java could be implemented in XWPFDocument.java in the future,
right?

Again, thank you very much for your help! :)


2015-05-13 10:42 GMT-07:00 Allison, Timothy B. <ta...@mitre.org>:

> Because content controls can be recursive and can be held within recursive
> structures, you have to recurse to get all of them.
>
> You might want to take a look at
> org.apache.poi.xwpf.usermodel.TestXWPFSDT's extractAllSDTs(XWPFDoc) as a
> model.
>
>
> -----Original Message-----
> From: Hayato Iriumi [mailto:hiriumi@gmail.com]
> Sent: Wednesday, May 13, 2015 2:26 AM
> To: user@poi.apache.org
> Subject: Getting all ContentControls
>
> Hello,
>
> I'm trying to get a list of ContentControls in a word document. I've got an
> instance of XWPFDocument, but getBodyElements or getBodyElementsIterator
> only gives me back the first level of the document elements. The Content
> Controls I have are children to the tables in the document.
>
> I was looking for a convenient method that returns me all the document
> elements, but I have not been able to find one. Should I write my own code
> to give me all the elements in a word document or does POI already have
> something like this?
>
> ---------------------------------------------------------------------
> 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: Getting all ContentControls

Posted by Hayato Iriumi <hi...@gmail.com>.
Timothy,

Thank you very much for your help! I was able to use the sample code (test
code rather) and get the result I wanted. I guess extractAllSDTs in
TestXWPFSDT.java could be implemented in XWPFDocument.java in the future,
right?

Again, thank you very much for your help! :)


2015-05-13 10:42 GMT-07:00 Allison, Timothy B. <ta...@mitre.org>:

> Because content controls can be recursive and can be held within recursive
> structures, you have to recurse to get all of them.
>
> You might want to take a look at
> org.apache.poi.xwpf.usermodel.TestXWPFSDT's extractAllSDTs(XWPFDoc) as a
> model.
>
>
> -----Original Message-----
> From: Hayato Iriumi [mailto:hiriumi@gmail.com]
> Sent: Wednesday, May 13, 2015 2:26 AM
> To: user@poi.apache.org
> Subject: Getting all ContentControls
>
> Hello,
>
> I'm trying to get a list of ContentControls in a word document. I've got an
> instance of XWPFDocument, but getBodyElements or getBodyElementsIterator
> only gives me back the first level of the document elements. The Content
> Controls I have are children to the tables in the document.
>
> I was looking for a convenient method that returns me all the document
> elements, but I have not been able to find one. Should I write my own code
> to give me all the elements in a word document or does POI already have
> something like this?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

RE: Getting all ContentControls

Posted by "Allison, Timothy B." <ta...@mitre.org>.
Because content controls can be recursive and can be held within recursive structures, you have to recurse to get all of them.

You might want to take a look at org.apache.poi.xwpf.usermodel.TestXWPFSDT's extractAllSDTs(XWPFDoc) as a model.


-----Original Message-----
From: Hayato Iriumi [mailto:hiriumi@gmail.com] 
Sent: Wednesday, May 13, 2015 2:26 AM
To: user@poi.apache.org
Subject: Getting all ContentControls

Hello,

I'm trying to get a list of ContentControls in a word document. I've got an
instance of XWPFDocument, but getBodyElements or getBodyElementsIterator
only gives me back the first level of the document elements. The Content
Controls I have are children to the tables in the document.

I was looking for a convenient method that returns me all the document
elements, but I have not been able to find one. Should I write my own code
to give me all the elements in a word document or does POI already have
something like this?

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


RE: Getting all ContentControls

Posted by "Murphy, Mark" <mu...@metalexmfg.com>.
Not real sure what you mean by this. Ask you question, and maybe someone can help you. Be sure to include what you did, what you expected to happen, and what actually happened instead. Showing your code is a good idea, and maybe attach the document as well.

-----Original Message-----
From: Shivam148 [mailto:jainshivam148@gmail.com] 
Sent: Wednesday, November 23, 2016 12:45 AM
To: user@poi.apache.org
Subject: Re: Getting all ContentControls

Hi ,
I am having some issue s with content control in POI . Can you help me with that ?



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Getting-all-ContentControls-tp5718805p5725733.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


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


Re: Getting all ContentControls

Posted by Shivam148 <ja...@gmail.com>.
Hi , 
I am having some issue s with content control in POI . Can you help me with
that ?



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Getting-all-ContentControls-tp5718805p5725733.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