cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding generating word doc from web Dynpro.

Former Member
0 Kudos

Hello Experts,

I have a requirement to generate word document using Web dynpro. This word document is a word template & everytime I execute web dynpro, data should be retrieved from the database tables & populated in the empty columns in the template.

Can anyone let me know if this is possible ? Would appreciate if any help / sample code is recieved.

Thanks,

RB

Accepted Solutions (0)

Answers (2)

Answers (2)

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

Create a single view with Text area,a button and a LinkTOUrl UI element. Write the following code on click of button. and set the refrence property of LinktoUrl equals to Url and value property or textedit to doc.

Note : Here Doc and Url are the value attribute of string type.

public void onActionConvert(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionConvert(ServerEvent)

final String formattedStr = wdContext.currentContextElement().getDoc();

try

{

final IWDCachedWebResource resource = WDWebResource.getWebResource

(

formattedStr.getBytes("UTF-8"), WDWebResourceType.DOC

);

resource.setResourceName("WordDoc.doc");

wdContext.currentContextElement().setUrl( resource.getAbsoluteURL() );

}

catch (final Exception ex)

{

wdComponentAPI.getMessageManager().reportException( new WDNonFatalException(ex), false );

}

//@@end

}

Write some info in text area and click the button.

and then click on LinktoURL UI element, it will ask you to save or open the word document.

hope it helps,

Regards,

Abhijeet.

Message was edited by:

abhijeet mukkawar

Former Member
0 Kudos

Hi Rajeshree,

please see this weblog:

/people/valery.silaev/blog/2005/11/23/display-formatted-text-using-webdynpro-for-java

You can also use the Java API to Handle Microsoft Word Files:

http://jakarta.apache.org/poi/hwpf/index.html

Hope this help you,

Vito