cancel
Showing results for 
Search instead for 
Did you mean: 

Create a workbook xlsx in an adapter module

Former Member
0 Kudos

Hi everybody,

In adapter receiver (file/FTP) , in an adapter module,

I want to create an excel file (format XLSX) ( input is the XML of normal flow).

I use apache POI to do that.

The manipulation of object XSSFWorkbook doesn't have any problem.

The problem comes when I want to convert the XSSFWorkbook created to the type ModuleData ( normal type for output ).

For an format xls , I use the workbook type HSSFWorkbook wihch has the method getByte() which convert the content of the wokbook to an array of byte ( bytes[]) which can be easily convert to ModuleData. But for the object type XSSFWorkbook that method doesn't exist.

Can somebody help me to do that conversion, please?

Kind Regards.

Eric Koralewski

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member181985
Active Contributor
0 Kudos

Hi Eric,

May be you have to use write() method inherited from immediate super class org.apache.poi.POIXMLDocument

Try as below,

ByteArrayOutputStream baos = new ByteArrayoutputStream();

XSSFWorkbook xssfobj = xxxx; //(As part of your code logic - some manipulation to this object xssfobj )

xssfobj.write(baos); //finally write to baos

inputModuleData.setPrincipalData(baos);

return inputModuleData;

Regards,

Praveen Gujjeti

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might want to search for JExcel API for creating Excel data format. Please refer this wiki and code presented by Shabarish on this

http://wiki.sdn.sap.com/wiki/display/XI/CODE+-+Create+an+Excel+File+via+the+JExcel+API

Plus how to handle the excel files in PI document is also below

http://scn.sap.com/community/pi-and-soa-middleware/blog/2009/04/05/excel-files--how-to-handle-them-i...

Please dont forget to rate this blog if you like it.

If you want more help on apache POI, Please share your code and required links for those api over here...