Skip to Content
0
Jun 27, 2019 at 07:29 AM

How to create .xls/.xlsx file with csv values from an incoming xml in SAP PI/PO using java mapping

309 Views Last edit Jun 27, 2019 at 07:30 AM 2 rev

Hi All,

I am trying to create a .xls/.xlsx file using Java mapping in SAP PO 7.5 with values inside the file being semicolon separated.

I have attached the screenshot for input xml and output file as reference.

capture.jpg

I am using DOM Parser to parse the input xml as below and then setting the value in the respective cells of the excel.

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder();

Document document = builder.parse(inputstream); NodeList nodelist = document.getElementsByTagName("ExchangeRate");

Please let me know how to add ; in between the different values fetched from the xml.

HSSFRow row1 = ITSFX.createRow(1);

cell = row1.createCell((short) 0);

cell.setCellValue(((Element) (nodelist.item(0))).getElementsByTagName("CurrencyFrom").item(0). getFirstChild() .getNodeValue());

Here i am getting the first value fetched from the xml i.e. EUR in this case.

Now i have to add the second value from the xml in the same cell [1,0] with semi colon as separator.

Attachments

capture.jpg (59.2 kB)