Java: byte [] Array in Excel for BLOB

I have a byte [] array that needs to be converted to a valid Excel spreadsheet. After converting the byte array, the Excel table should be cached into the database, preferably as a BLOB.

First I tried to create a WritableWorkbook with:

WritableWorkbook workbook = Workbook.createWorkbook(byteArrayOutputStream); ... workbook.write(); 

This will be good for me, but I have no idea how to store the book as a BLOB in a database. Is it possible? Or is there another way?

Optional: instead of the byte [] array, I could also use a deserialized object.

Workbook API: http://jexcelapi.sourceforge.net/resources/javadocs/2_6_10/docs/jxl/Workbook.html

+4
source share
2 answers

The jdbc PreparedStatement#setBlob() method accepts an InputStream as an argument to a data source. Just create a ByteArrayInputStream above the buffer of your byteArrayOutputStream and go to setBlob() .

+3
source

There is no method in jxl from which we can get the output stream or byte array from writeableWorkSheet.

+1
source

All Articles