Error downloading spreadsheet

Sep 23, 2011 at 5:28 PM

Hello,

 

Using NPOI version 1.2.3 with asp.net MVC3.  

I am creating a spreadsheet from data that resides in a database table.  My test is creating a spreadsheet with 258 rows that has 7 columns.

When I click on the Open dialog in IE I get the following error:  <Spreadsheet> could not be downloaded.  When I click on the Retry button, the spreadsheet downloads and successfully opens.

When I modify the sample asp.net application to create several rows I do not get the retry error.  It appears to be related to the size of the spreadsheet.  

Any ideas on how to address this problem?

 

Here is a snippet of the code:

 

 // Getting the complete workbook...               

HSSFWorkbook templateWorkbook = new HSSFWorkbook(fs, true);

 // Getting the worksheet by its name...               

HSSFSheet sheet = (HSSFSheet)templateWorkbook.GetSheet("Sheet1");
foreach (var row in PagedViewModel.Query)               

{          

HSSFRow rownum = (HSSFRow)sheet.CreateRow(rowCnt);                   

rownum.CreateCell(0).SetCellValue(row.Id.ToString());                   

rownum.CreateCell(1).SetCellValue(row.SurveyId.ToString());                   

rownum.CreateCell(2).SetCellValue(row.ModelNumber.ToString());                   

rownum.CreateCell(3).SetCellValue(row.Series.ToString());                   

rownum.CreateCell(4).SetCellValue(row.Year.ToString());                   

rownum.CreateCell(5).SetCellValue(row.Season.ToString());                   

rownum.CreateCell(6).SetCellValue(row.PostedDate.ToString());                   

rownum.CreateCell(7).SetCellValue(row.Answer.ToString());                   

rownum.CreateCell(8).SetCellValue(row.Comments);                   

rownum.CreateCell(9).SetCellValue(row.Type);                   

rownum.CreateCell(10).SetCellValue(row.Topic);                   

rownum.CreateCell(11).SetCellValue(row.Details);                   

rowCnt++;               

}

 // Forcing formula recalculation...               

sheet.ForceFormulaRecalculation = true;

 // Writing the workbook content to the FileStream...               

templateWorkbook.Write(ms);

 return File(ms.ToArray(), "application/vnd.ms-excel", "NPSProcessedNewFile.xls");

 

Xia Xia

Joe

Coordinator
Oct 16, 2011 at 10:30 PM

I'm afraid this issue is caused by your asp.net app instead of NPOI, which is out of scope. If you still need help, I may provide NON-FREE support this. Please contact me via tonyqus (at) gmail.com