on 11-20-2013 5:39 AM
Can someone please elaborate on how we can export data to word template (.docx) from Webdynpro Java application ?
I need to export data to pre-defined fields in a word template (.docx).
Any help/clues will be greatly appreciated. Thanks!
Try this, It will solve your prob.
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.
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
}
Or try this
import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class ReadDocFile {
public static void main(String[] args) {
File file = null;
WordExtractor extractor = null ;
try {
file = new File("c:\\New.doc");
FileInputStream fis=new FileInputStream(file.getAbsolutePath());
HWPFDocument document=new HWPFDocument(fis);
extractor = new WordExtractor(document);
String [] fileData = extractor.getParagraphText();
for(int i=0;i<fileData.length;i++){
if(fileData[i] != null)
System.out.println(fileData[i]);
}
}
catch(Exception exep){}
}
}
Please go through this document http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/3483789514b748b6fe1f145e9685ab/content.htm
Regards
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As Jun said, its more to do with your jova code to prepare the Word file.
You could make use of Apache POI/ doc4j jar files in WD project. Use the api methods to build the file and populate the data from the wd context variables.
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
nothing to do with web dynpro
just use your java knowledge to get it done.
you can some open source from apache...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.