cancel
Showing results for 
Search instead for 
Did you mean: 

Create MS-Word document and write context data to it

bernd_speckmann
Contributor
0 Kudos

Hi all,

I have to generate / create a word document which should contain data from my web dynpro app received from a web service.

The document should be created by clicking on a button and displayed using office control.

Is this possible? if it is, what's the best way to deal with this issue?

Thanks a lot

Bernd

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Bernd,

the best way is if the content comes from WD.



IWDResource resource = null;
byte[] data = null;  
String filename ="yourfileName";
data= bufferString.getBytes("UTF-8");
resource = WDResourceFactory.createResource(data, fileName + ".doc", WDWebResourceType.DOC);
			wdContext.currentContextElement().setResourceExport(resource);

The bufferString is the buffer where you create the content for the Word Document.

In the context you must create a value attribute (here resourceExport) from the type com.sap.ide.webdynpro.uielementdefinitions.Resource

This resource you can bind to a fileDownload element.

I hope this helps.

Regards

Gunter

Answers (0)