By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,649 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,649 IT Pros & Developers. It's quick & easy.

xlsx file not able to open when its downloaded

P: 1
Hi
I have load the xlsx file in blob using POI
when i tried to download the xlsx file from blob the xlsx file got saved but its not openening. when i tried to open the file its giving following error
The conerter failed to open the file.

Please help me Did i mistake anything in my code.

upload the file:
fileOutStream = new FileOutputStream(newFileName);
xlsxWorkbook.write(fileOutStream);
fileOutStream.flush();
fileOutStream.close();
File newFile = new File(newFileName);
jobDetailTO.setData(FileUtils.readFileToByteArray( newFile));
new JobDetailBD().insertJobBlob(jobDetailTO);

This is the query load in oracle DB
INSERT INTO USER_TOOL_SPREADSHEET(JOB_ID,
SPREADSHEET) values (#jobIdSUID#, #data#)

Download from oracle

outFileName = "FileName.xlsx";
response.setHeader("Content-Disposition", "attachment; filename= "+ outFileName);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8");
JobDetailTO jobTO = jobDetailBD.getJobBlob(jobDetailTO.getJobIdSUID()) ;
byte[] outFileArray = jobTO.getData();
ByteArrayInputStream bis = new ByteArrayInputStream(outFileArray);
out = new BufferedOutputStream(response.getOutputStream());
int byteRead = 0;
while ((byteRead = bis.read()) != -1) {
out.write(byteRead);
}
out.flush();
bis.close();
out.close();
Please help me out to resolve the issue
Jun 6 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.