Export whole page to Excel with infragistics in ASP.NET C#





0/5 (0 vote)
Tip: Change your loop to the following to also support derived classes:foreach (var item in controlList ){ GridView asGridView = item as GridView; if (asGridView != null) { Utilities.RenderControlInExcel(asGridView, workBook); } DetailsView asDetailsView =...
Tip: Change your loop to the following to also support derived classes:
foreach (var item in controlList )
{
GridView asGridView = item as GridView;
if (asGridView != null)
{
Utilities.RenderControlInExcel(asGridView, workBook);
}
DetailsView asDetailsView = item as DetailsView;
if (asDetailsView != null)
{
detailsRowStart = Utilities.RenderControlInExcel(
asDetailsView, detailsSheet, detailsRowStart);
}
Add a using
statement to WriteToResponse
:
using(System.IO.MemoryStream theStream = new System.IO.MemoryStream()){
//... code.....
}
The term view.Rows[row].Cells[col].
is used many times. Extract to a variable to improve performance and readability.