I have the Spring REST service returns the excel file(XLS) as byte array and need to write the appropriate client code to receive this response and save the file. Was able to get the byte array response but while converting it to excel workbook(HSSFWorkbook) getting the below error
org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0x0005060000100809, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document.
I tried the following but no luck
- verified that the file is valid by saving it in the service before returns in response.
- Tried to send the InputStream instead of byte array
- Tried using ResponseEntity etc
service side code
HSSFWorkbook workbook = //code to generate the workbook
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
workbook.write(outputStream);
byte[] response = outputStream.toByteArray();
Any help is greatly appreciated.