permaculture playing cards*
The moose likes Other Open Source Projects and the fly likes Excel file is corrupted when i download it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Excel file is corrupted when i download it " Watch "Excel file is corrupted when i download it " New topic
Author

Excel file is corrupted when i download it

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 243

hi, i have generated excel file using Apache POI .it is generated in my root path under excel folder.when user click save as excel the created file should download to user chosen location. it is get downloaded to that perticular path given by user but, when i try to open a message is showing like this file format corrupted ......my code on click of button on jsp is

but the generated code is giving a corrupted excel file
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 243

It is working when i deployed it on web not in local system why?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

You shouldn't use JSP files to display any binary file, including Excel files. Any whitespace between tags (like at the top, between import directives) can already be added to the output. That will cause corruption of binary files. Instead, use a servlet to display the binary file.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 243

thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

You're welcome.
 
 
subject: Excel file is corrupted when i download it
 
Similar Threads
Reading and writing an Excel file from one place to another
What's the best way to download files from a web app?
download link in jsp ?
Implementing download - XLS files - JSP scriptlet
How to handle Servlet Exception Correctly