on 10-19-2007 2:10 PM
Hi to all,
I want to use an Adapter Module to convert an excel .xls file into an xml document. Does a Standard Module Bean exist that performs this conversion? Or, I have necessary to write a custom Java Adapter Module Bean?
Thanks to all!
Hi Gabriele,
you can use the Conversion Agent for Excel to XML conversion,
i.e,
CSS note :-
#894815 FAQ: NetWeaver Conversion Agent by Itemfield
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/43/4c38c4cf105f85e10000000a1553f6/content.htm">SAP Help online - Conversion Agent</a>
Regards
Kenny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gabriele,
For more details and for downloading Conversion Agent(CA) check out this URL...
/people/william.li/blog/2006/03/17/how-to-get-started-using-conversion-agent-from-itemfield
For one of my interface in last project we had same requirement...reading Excel File...Even I had a thought of using CA..but I feel we get better control using writing adapter module..you can read multi tab xls sheet as well..
For generating excel file without using CA or writing adapter moduel you can refer this Michals blog..
/people/michal.krawczyk2/blog/2005/12/10/xi-generating-excel-files-without-the-java-nor-the-conversion-agent-not-possible
For reading xls file check out this thread which I have used while generating module..
/people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter
In case if you are planning to write adapter module...you might need to debug your code...here is a thread which shows how to debug code..
Let me know if you need more details.
Nilesh
U can either use content conversion or Adapter module.
I did this through Adapter Module
First of all download jxl.jar for adding in your project in NWDS
Please find the attache code
Please find the snippet of the code this might help u.
keep in mind to add the jxl.jar and import the same.
public class ImportPdfBean implements SessionBean {
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext context) {
myContext = context;
}
private SessionContext myContext;
public void ejbCreate() throws CreateException {
}
public ModuleData process(
ModuleContext moduleContext,
ModuleData inputModuleData)
throws ModuleException {
Object obj = null;
Message msg = null;
String msgType = null;
String nameSpace = null;
try {
obj = inputModuleData.getPrincipalData();
msg = (Message) obj;
msgType = (String) moduleContext.getContextData("msgType");
nameSpace = (String) moduleContext.getContextData("nameSpace");
XMLPayload xmlpayload = msg.getDocument();
if (xmlpayload != null) {
xmlpayload.setContent(
convertToText(xmlpayload, msgType, nameSpace));
inputModuleData.setPrincipalData(msg);
}
} catch (Exception e) {
ModuleException me = new ModuleException(e);
throw me;
}
return inputModuleData;
}
private byte[] convertToText(
XMLPayload xmlpayload,
String msgType,
String nameSpace)
throws Exception {
String textData = null;
String encoding = null;
int startPage = 1;
int endPage = Integer.MAX_VALUE;
PDDocument document = null;
String retXMLData = null;
try {
// Get PDDocument from the file content
document = PDDocument.load(xmlpayload.getInputStream());
ByteArrayOutputStream by = new ByteArrayOutputStream();
OutputStreamWriter out = new OutputStreamWriter(by);
PDFTextStripper stripper = null;
stripper = new PDFTextStripper();
stripper.setStartPage(startPage);
stripper.setEndPage(endPage);
stripper.writeText(document, out);
textData = by.toString();
retXMLData =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"
+ "<ns:"
+ msgType
+ " xmlns:ns=\""
+ nameSpace
+ "\">\n"
+ "<TextData>"
+ textData
+ "</TextData>\n"
+ "</ns:"
+ msgType
+ ">";
} catch (Exception e) {
}
return retXMLData.getBytes();
}
}
in Adapr give the path as localejs/sap.com/< projectname>
<projectname> the package that you have deployed on the server
*********************Please reward point if find useful*******************
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have a look at this blog
/people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter
Regards,
Sreenivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For converting a csv file into xml file you can use file content conversion in file adapter. ref to this blog for doing this:
/people/sap.user72/blog/2005/01/06/how-to-process-csv-data-with-xi-file-adapter
But, for converting .xls file into xml file you have to go for adapter module
Regards,
Sreenivas
you can try file adapter to convert xls file to xml file.
regards
Bin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I beleive you have to write module using java api for reading excel file
thanks
farooq.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.