Telerik RadGrid can export your data to the following formats:
Common properties and events
In addition to the export format's specific properties, the ExportSettings group exposes several
As the name says, this property is helpful when you want to export only the data - e.g. to exclude the controls
from the exported file.
When you enable IgnorePaging, RadGrid will rebind before export
in order to fetch all the data from your datasource.
By default, the exported file will be handled by the program associated with the appropriate file type.
If you prefer to give the user the option to choose whether to save, open (inline) or cancel you should enable this property.
Even if you set OpenInNewWindow="false", that doesn't guarantee that the file will be opened inside
the browser window. The way the exported file will be displayed inline depends on the
The end-user could manage the file extensions with programs like NirSoft's FileTypesMan. For browsers, other than Internet Explorer, you should use the built-in settings.
This is helpful when you want to give a predefined name for your file. Please note that the file name can't be longer
than 256 symbols.
Unicode names are not supported out-of-the-box for Internet Explorer6 and 7. Of course you can manually encode the file name and it will be shown
properly in the "Save" dialog (OpenInNewWindow="true").
HttpUtility.UrlEncode("unicode string", System.Text.Encoding.UTF8);
Internet Explorer ignores the FileName property when
OpenInNewWindow is set to false.
Removes the structure columns - GridRowIndicatorColumn, GridExpandColumn
as well as the first GridGroupSplitterColumn. Note that this property will affect only the first
level in hierarchical RadGrids.
You can receive this error if the file name is longer than 256 symbols:
'<filename>.<extension>' could not be found. Check the spelling of the file name, and verify that the
file location is correct.
This property will help avoid exporting already formatted values which
would cause Microsoft Excel to treat them as string values.Enabling this functionality will result in rebinding the control
before exporting. Note that even if both IgnorePaging and
SuppressColumnDataFormatStrings are enabled, RadGrid will rebind only once.
As the name says, this property gives you the ability to apply the item styles to the exported file.
This event is useable in many scenarios when you want to modify the output file - for example you may want to add some custom
information above RadGrid or when you want to remove/add/replace parts of the content.
The only limitation applies to the PDF export because by the time the
OnGridExporting event is raised, the PDF is already generated.
For more information, please visit the dedicated PDF format topic which introduces the
OnPdfExporting event that is designed specifically for this format.
Below is the barebone logic for OnGridExporting event:
Exporting with client-side binding is not supported, RadGrid should be bound
server-side, otherwise you will receive an empty file.
RadGrid exporting works only when the ViewState is persisted in a hidden field (default). In case you are using an
alternative way to persist the ViewState such as storing it in a database or a session, you will receive an exception.
Exporting a large amount of data
We strongly recommend not to export large amounts of data since there is a chance to encounter an exception
(Timeout or OutOfMemory) if more than one user tries to export the same
data simultaneously. RadGrid is not suitable for such scenarios and therefore we suggest that you limit
the number of columns and rows. Also it is important to note that the hierarchy and the nested controls have a considerable effect
on the performance in this scenario.
Export with custom paging
When you have custom paging enabled for your grid, you need to set the PageSize property of the grid
to be equal to the VirtualItemCount in order to export all records successfully with
IgnorePaging set to true. Here is an example:
Export from AJAX-enabled RadGrid
Nested grids / Exporting multiple RadGrids
Export with client-side binding
RadGrid doesn't support exporting with client-side binding.
To be able to export in such scenario, you should bind RadGrid on the server.
Export in SharePoint webpart
Export in web farm
If you receive "Invalid ViewState" or similar exception in web farm scenario, you can try to copy the
machinekey from your web.config to the
machine.config of the web server.
Export over SSL
You might receive the following error message when using the export feature over SSL and
"Internet Explorer cannot download 'file' from 'server'.
Internet Explorer was not able to open this Internet site. The requested site is either
unavailable or cannot be found. Please try again later."
In order to prevent this error add the following lines just before the exporting:
The following methods are marked as obsolete as of RadGrid v4.6 (part of UI
ExportToWord(fileName, dataOnly, ignorePaging)
ExportToExcel(fileName, dataOnly, ignorePaging)
ExportToWord2007(fileName, dataOnly, ignorePaging)
ExportToExcel2007(fileName, dataOnly, ignorePaging)
For real-life example, review our online demo.