cancel
Showing results for 
Search instead for 
Did you mean: 

Excel to XML conversion

Former Member
0 Kudos

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!

Accepted Solutions (0)

Answers (5)

Answers (5)

kenny_scott
Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Kenny,

it is a good Idea, thanks! But... it is an internal XI Component? Or it is an external tool? How can I use it?

Thanks!

kenny_scott
Contributor
0 Kudos

Hi Gabriele,

it is a tool that is distributed by SAP to create Adapter modules for use with PI/XI.

You should be able to download it from the Service Marketplace.

Regards

Kenny

Former Member
0 Kudos

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..

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3bdc14e1-0901-0010-b5a9-a01e29d7...

/people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/02706f11-0d01-0010-e5ae-ac2...

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

Former Member
0 Kudos

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*******************

Former Member
0 Kudos

Hi,

Have a look at this blog

/people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter

Regards,

Sreenivas

Former Member
0 Kudos

try this

/people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter

thanks

farooq.

Former Member
0 Kudos

Hi,

I know this blog. But... there is a way to perform xls to xml conversion with STANDARD modules or by STANDARD FILE ADAPTER SETTINGS?

Thanks!

Former Member
0 Kudos

Hi,

There is no standard settings for the excel to xml conversion, you need to write java code.

Regards,

Sreenivas

Former Member
0 Kudos

Hi,

yes, but I know that an Excel file is a CSV (Coma Separated Value) file, than this information can anyway help me?

Thanks!

Former Member
0 Kudos

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

0 Kudos

you can try file adapter to convert xls file to xml file.

regards

Bin

Former Member
0 Kudos

I beleive you have to write module using java api for reading excel file

thanks

farooq.