Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

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

0.00/5 (No votes)
6 Nov 2011CPOL 7.3K  
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:


C#
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:


C#
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)