Tips, Tricks and Code Tips, Tricks and Code

Back

Java Service to convert StringList and DocList to XLS - ToExcel Utility

Created by Mahesh K. Sreenivasulu Sreenivasulu, last modified on Tue, 27 Aug 2019, 04:32

Hi All,

Attached is the java utility service that will convert StringList/DocList/StringTable to XLS and the same can be saved or emailed. 

Note: The service uses "poi-4.1.0.jar" and it is embedded in the IS package, the code has been tested on IS 10.4 with JDK 1.8.0_201 (52.0)

By default the file gets saved at the location "C:\SAG_Home\IntegrationServer" and this can be overridden by specifying the input file path "file_name" in the core java services:

ToExcel.util:docListToMSExcel
ToExcel.util:stringListToMSExcel


ToExcel.helper:stringTableToDocList (helper service to convert StringTable to DocList)

Refer to the below demo services and contact me if you have any questions.

ToExcel.demo:docListToExcel
ToExcel.demo:stringListToExcel
ToExcel.demo:stringTableToExcel

 

Thanks,

Mahesh K Sreenivasulu


1 Attachment
397 Views
Average (1 Vote)
Comments
Hi,

I am new on Java and webMethods, the only thing being doing and familiar with is working on flow service. So what do I do with those 2 files and i managed to get them, mind walking me the steps?
Posted on 8/21/19 6:05 AM.
Hi,
I have see you examples issue is StringList its a List obviously, so i would like to writing into excel in record that


e.g (More like how I saw 'String Table' handle data just i could output it)
ID Name Surname Age Gender
1 Ford Doe 22 Male
2 Lord Star 30 Male
3 Ohura Spork 32 Female
Posted on 8/21/19 10:37 AM.
Hi,
Can you share the screenshot of your stringList or documentList?
Posted on 8/21/19 10:41 AM in reply to Stanley Manoto.
From the reply seems i can post screenshots
Posted on 8/21/19 10:51 AM in reply to Mahesh K. Sreenivasulu -.
"Can't"

Cannot edit or delete comments emoticon
Posted on 8/21/19 10:53 AM.
Your example are clear, i can do the same as you did.

but what i am requesting is to write into excel fine in columns and rows not only in a list

e.g (wanna write this way)

ID Name Surname Age Gender
-----------------------------------------------------------------
1 Ford Doe 22 Male
2 Lord Star 30 Male
3 Ohura Spork 32 Female


Columns and Rows as My data comes from a oracle database and obviously i'd like headinga for my records
Posted on 8/21/19 11:01 AM.
Managed to insert my screenshot under yours
Posted on 8/21/19 11:02 AM.
Saw your screenshots and I see you want to insert the StringTable data in the XLS file. Let me check this and revert or you can use the attached code as a reference and build one that supports StringTable.

I am deleting your screenshots that are attached to this article.
Posted on 8/26/19 11:03 AM in reply to Stanley Manoto.
Updated the ToExcel.zip to support StringTable, check the demo service "ToExcel.demo:stringTableToExcel"
Posted on 8/27/19 4:31 AM in reply to Stanley Manoto.
Posted on 8/27/19 6:49 AM in reply to Mahesh K. Sreenivasulu -.
All 3 are working as required, issue is I can't have column headings on the docListToMSExcel sevice, any advice?
Posted on 8/27/19 8:58 AM in reply to Mahesh K. Sreenivasulu -.
It does work, in my sample demo "name" is the column header.
Posted on 8/27/19 9:17 AM in reply to Stanley Manoto.
Thanks, I don't know whats happening but headings ain't showing in the xls doc after execution.
Posted on 8/27/19 1:14 PM.
Thanks, I don't know whats happening but headings ain't showing in the xls doc after execution.
Posted on 8/27/19 1:14 PM.
its on the stringList, I would like to see it on the docList.
Posted on 8/27/19 1:31 PM.
Mahesh,

Please help on the last comment, also as docList writes to excel in a form of batch, i would like to filter record using a loop, how would i write records in an excel document(1) one entry at time sort of amending nor replacing, please advice?
Posted on 9/4/19 1:14 PM.