Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

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

, 6 Nov 2011 CPOL
Rate this:
Please Sign up or sign in to 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.

License

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

Share

About the Author

Kabwla.Phone
Software Developer (Senior)
Netherlands Netherlands
Doing that 'computer thing' ever since the C64.
 
Sometimes I feel that being a programmer is much like being a doctor: You just have to know everything and if you don't, something dies.
 
Either being an appliction or a patient.
Oddly enough, more people care about the death of their application, than the massacre op people...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 6 Nov 2011
Article Copyright 2011 by Kabwla.Phone
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid