PROJECT DESCRIPTION
Code Library sample that demonstrates Exporting RadGrid with an Image as Header for both PDF and Excel.
Export Image as Header for PDF
Did you know that the CommandItemTemplate of RadGrid can also be exported if the ExportSettings-ExportOnlyData property is set to False, and that it can be used to build a header for the exported files? Since setting Headers/Footers for the exported document is limited, this could be a viable workaround to export your company logo, banner as header.
This sample is using the approach from the Grid - Export to PDF demo except that it spans the header until the edges without margin/padding.
Settings for the PDF Page (I've defined the properties in the markup, but it can be set in the code behind as well)
Markup - CommandItemTemplate containing an Image
Markup - Of course, the CommandItem does not have to be visible at all times, you can use the following approach to only show it during the export event.
Finally, the code behind that will span the image over the CommandItem cells.
C#
VB
It is now ready to be exported (the sample uses a button, but it's not limited to)
C#
VB
Export Image as Header for Excel
For excel, we will change the approach a little bit, and we'll follow the
Image Support section of the
Export Infrastructure article to add the image.
Markup - Set the Excel Format to Biff.
Image applied inside the InfrastructureExporting event handler
C#
VB
To apply additional style to RadGrid before it gets exported, you can do that in the PreRender event handler
C#
VB
And then export.
C#
VB