This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

download to excel in a zip file  RSS feed

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
How do they get the deer to cross at the signs? Or to read this tiny ad?
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!