File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes download to excel in a zip file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "download to excel in a zip file" Watch "download to excel in a zip file" New topic

download to excel in a zip file

ank Gupta

Joined: Jun 20, 2008
Posts: 6
Hello All,

We have a download to excel feature where user can download data in excel format. We are using JSF framework but since this feature as such is not related to JSF i am asking it in servlets. TYhe problem is that file size is getting heavy (around 40 mb), so user is not able to download it properly getting errors like (the server returned an invalid or unrecognized response) or (page cannot be displayed.) sometimes download box dissappears while downloading .

We have same data in our development and testing env where its working fine. Can somebody suggest some solution? I was thinking of converting that excel to zip file . Is it possible. need help.

Here is a code snippet for download to excel.

public boolean exportToExcel(ArrayList<ExportToExcelVO> listVO,
String fileName, String fileHeading, HttpServletResponse response) {

final LoggerImpl logger = new LoggerImpl(ExportToExcelBean.class);
ExportToExcelVO vo;
boolean result = false;
String contentType = "application/";
response.setHeader("Content-disposition", "attachment; filename="
+ fileName);
try {
PrintWriter out = response.getWriter();
if (!(fileHeading.equalsIgnoreCase(""))) {
out.println(fileHeading + "<br><br>");
for (int k = 0; k < listVO.size(); k++) {
if (!(vo.getStrHeading().equalsIgnoreCase(""))) {
if (!(vo.getStrTableHeading().equalsIgnoreCase(""))) {
out.println("<hr><br><table border='1' cellpadding='1' cellspacing='1'>");
for (int i = 0; i < vo.getListRowsToExcel().size(); i++) {
for (int j = 0; j < vo.getNoOfRowsBetweenRows(); j++) {

} catch (IOException e) {
logger.error("IO EXCEPTION in Export To Excel Bean");
result = false;
return result;

and this code is called from following code :
ExportToExcelVO vo = new ExportToExcelVO();
ExportToExcelBean expExclBean = new ExportToExcelBean();
ArrayList<ExportToExcelVO> listVO = new ArrayList<ExportToExcelVO>();

// lisrRows contains all the data to be exported to excel.

FacesContext fc = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) fc
expExclBean.exportToExcel(listVO, fileName, fileHeader, response);
I agree. Here's the link:
subject: download to excel in a zip file
It's not a secret anymore!