Send Excel or xls file to remote directory using spring integration

558 Views Asked by At

I have generated an Excel file using Apache POI API and trying to send it to remote directory using Spring Integration, but when I am writing below code giving compile time error because its only support "File" type object Excel type is "HSSFWorkbook".

HSSFWorkbook workbook = gerateExcelFile(data);

excelCollector.add((workbook);

and using below code for "inbound-channel-adaptor"

<inbound-channel-adapter id="excelAdapter" auto-startup="true"
                 ref="excelCollector" method="poll" channel="excelInputChannel">
    <poller fixed-rate="500"/>
</inbound-channel-adapter>
1

There are 1 best solutions below

2
On

The framework does not know how to process arbitrary objects.

You either need to write the workbook to a File or convert it to a byte[] containing the workbook contents, and send that.