$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
GridView Exporting in ASP.NET AJAX
Home > How to > Grid Exporting
The DataGrid Controls for ASP.NET WebForms applications are an amazing component for design modern user interface. This cool control provides large flexibility to meet any critical requirements of applications nowadays. Furthermore, The ASP.NET Data Grid Control for Web Forms provides support of the data exporting to a variety of file formats, including, PDF, Excel, Word, CSV, or plain text. All data customizing or formatting applied can be exported to these files.

Supported File Formats

KAX.Grid can export grid data to four file formats:
  • CSV: using method ExportToCSV()
  • PDF: using method ExportToPdf()
  • Excel: using method ExportToExcel()
  • Word: using method ExportToWord()
The Kettic GridView ASP.NET component provides the support of exporting data from grid to Microsoft Office document. This feature needn't the MS Office installation, however, allows the exported Excel or Word file being read in MS Excel spreadsheet/Word document 2003 and higher versions. At the same time, if you want to export the asp.net gridview to PDF document, there also no need Adobe software installaltion.

And users can changing the parameter FileName to customize the exported file name.

Exporting with Paging

If you want only to export current showing page in the grid, just set IgnorePaging property to False. And then, the output file only contains the current page data.
If you want to export all the data in the grid, you need set IgnorePaging property to True, and set PageSize property to the VirtualItemCount. When you export multiple pages of asp.net gridview out to Excel, the data will fill with multiple spreadsheets in the Excel, one page data is one sheet.
C# sample code:

KaxGrid1.PageSize = KaxGrid1.MainView.VirtualItemCount;
KaxGrid1.ExportSettings.IgnorePaging = true;
KaxGrid1.ExportSettings.OpenInNewWindow = true;

Exporting with custom Rows

If you don't want to export the whole data out from the asp.net gridview, Kettic allows you export any parts of the grid view, such as single or multiple rows with continuous or discontiguous index.
C# example code:

int index = 0;
foreach (GridDataItem item in KaxGrid1.MainView.Items)
item.Visible = true;
item.Visible = false;

Exporting with custom Columns

Similar with export rows, users can also determine which columns to export from the asp.net grid view.
C# code:

KaxGrid1.MainView.GetColumn("UserId").Visible = false;

Exporting with custom Style

When you export the data out to the file, the grid appearance or skin will not work in the file. If you want to make your exported file look different, you may change the GridDataItem.Style property. Additional, not only the skin, but also the grid layout, page layout will keep the original style in the asp.net gridview. And the font size, color, formatting will be hold. Note: this property only support exporting to PDF, Excel and Word.
C# code:

foreach (GridDataItem item in KaxGrid1.Items)
item.Style["background-color"] = "#123456";

Resizing columns

You can set HeaderStyle.Width property to change the column size before export the data out to the file. And this property is only working for exporting to PDF, Excel and Word.
ASPX code:

<kettic:GridBoundColumn DataField=" UserID ">
<HeaderStyle width="200px" />
C# code:

GridColumn column = KaxGrid1.MainView.GetColumn("UserID");
column.HeaderStyle.Width = 200;