Wednesday, September 23, 2015

Use a DevExpress ASPxGridViewExporter to make an Excel sheet of the rows in an ASPxGridView!

Put one in the markup like so...

<dx:ASPxGridViewExporter ID="MyExporter" runat="server" GridViewID="MyGrid">
</dx:ASPxGridViewExporter>

 
 

...wherein MyExporter is wired up to scrape the rows of MyGrid, and then, at the right spot in C# in your workflow, call out to it (MyExporter) like so:

GridExporter.FileName = "Whatever";
GridExporter.WriteXlsToResponse();

 
 

Google Chrome will just start downloading Whatever.xls based upon the C# above once it's triggered. Note that if you don't want to show a column in the excel sheet you need to first hide it at the ASPxGridView. There may also be another way to go about this at the ASPxGridViewExporter itself, but I haven't researched it and I'm just keeping it simple for this example. Other options beyond dumping to a .xls seem to include:

  • WriteCsvToRepsonse
  • WritePdfToResponse
  • WriteXlsxToResponse

No comments:

Post a Comment