I am new to the whole issue of generating/sending Excel report in ASP.net. Code below sometimes does not work for large amount of data (large Excel report). Client has IE9 and MS Office 2010. Client does not get any errors, client simply does not get report after long wait time. Are there any alternative to the approach below, for providing client with large Excel report ? Anything done wrong in the code below that may cause the problem. All replies are appreciated.
Code:
Response.ContentType = "application/ms-excel"
Response.AddHeader("Content-Disposition", "attachment; filename=" + ReportName + ".xls")
Response.Write("<table border =1>")
For Each ch As ColumnHeaders In arrCh
If ch.ColumnName <> "" Then
pCh = pCh & "<td><b>" & ch.ColumnName & "</b></td>"
pColCount = pColCount + 1
End If
Next
If pExtraHeader <> "" Then
Response.Write(pExtraHeader)
End If
Response.Write("<tr>" & pCh & "</tr>")
If oSQLDataReader.HasRows Then
Do While oSQLDataReader.Read()
Response.Write("<tr>")
For I = 0 To arrCh.Count - 1
If arrCh(I + 1).columnname <> "" Then
Response.Write("<td>" & strColumnValue & "</td>")
If arrCh.Item(I + 1).isTotal = True Then
arrCh.Item(I + 1).placeholder = CDbl(arrCh.Item(I + 1).placeholder) + CDbl(oSQLDataReader.GetValue(I))
End If
End If
Next
Response.Write("</tr>")
Loop
Dim pTotal As String = ""
For Each ch As ColumnHeaders In arrCh
If ch.ColumnName <> "" Then
pTotal = pTotal & "<td><b>" & strColumnValue & "</b></td>"
End If
Next
Response.Write("<tr>" & pTotal & "</tr>"
End If
Response.Write("</table>")
Comment