Quantcast
Channel: SCN : All Content - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 7030

Issue in Excel to XML Conversion

$
0
0

Hi Gurus,

 

I am creating a custom java module in sap nwds 7.3 for Excel to XML Conversion. But I am getting following error

 

Classpath dependency validator message.

 

Classpath entry  will not be exported or published. Runtime ClassNotFoundExceptions may result.


I imported the Jars from a different PI system and i am using NWDS in local PC with creating a separate folder with all JARs and also imported them using build path option.

 

This issue is occuring for all the jars imported.

 

I am using following code.

 

 

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.Map;

import com.sap.aii.mapping.api.StreamTransformation;

import com.sap.aii.mapping.api.AbstractTrace;

import java.util.HashMap;

import jxl.Cell;

import jxl.Workbook;

public class JavaMappingExcelToXML implements StreamTransformation{

private Map map = null;

private AbstractTrace trace = null;

public void setParameter(Map arg0) {

map = arg0; // Store reference to the mapping parameters

if (map == null) {

this.map = new HashMap();

}

}

/*

public static void main(String args[]) { //FOR EXTERNAL STANDALONE TESTING

try {

FileInputStream fin = new FileInputStream ("c:/ashu.xls"); //INPUT FILE (PAYLOAD)

FileOutputStream fout = new FileOutputStream ("C:/Users/ashutosh.a.upadhyay/My Documents/ashuXML2.xml"); //OUTPUT FILE (PAYLOAD)

JavaMappingXLStoXML mapping = new JavaMappingXLStoXML ();

mapping.execute(fin, fout);

}

catch (Exception e1) {

e1.printStackTrace();

}

}*/

 

 

public void execute(InputStream inputstream, OutputStream outputstream) {

String msgType = "Message Type name will come here";

String nameSpace = "Namespace Name will come here";

String xmldata = "";

try {

Workbook wb = Workbook.getWorkbook(inputstream);

xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\n">";

Cell[] cells ;

Cell[] cellNames ;

cellNames = wb.getSheet(0).getRow(0);

 

 

for(int j=1;j<wb.getSheet(0).getRows();j++){

xmldata = xmldata+"\n<Record>\n";

cells = wb.getSheet(0).getRow(j);

for(int i=0;i<wb.getSheet(0).getColumns();i++){

xmldata = xmldata+"\t<"+cellNames[i].getContents()+">"+cells[i].getContents()+"</"+cellNames[i].getContents()+">\n";

}

xmldata = xmldata+"</Record>";

}

xmldata = xmldata+"\n</ns0:"+msgType+">";

System.out.print(xmldata);

xmldata.getBytes();

wb.close();

byte by[] = xmldata.getBytes();

outputstream.write(by);

inputstream.close();

outputstream.close();

System.out.println("\n"+"File processed");

}

catch (Exception e) {

e.printStackTrace();

}

}

}

 

Request you to guide how to resolve this issue.

 

 

Thanks  in advance


Viewing all articles
Browse latest Browse all 7030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>