This is a migrated thread and some comments may be shown as answers.

Grid Custom Export method

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sheik Alavudeen
Top achievements
Rank 1
Sheik Alavudeen asked on 24 Jul 2010, 03:20 PM
Hi,

I need to add the Company Logo for each grid export options. In footer of report, we need to show the User Name and Page Info and Printed Date and Time for each page of the data report. I tried with the below method. but its not working.

protected

 

void gridSalaryInfo_GridExporting(object source, Telerik.Web.UI.GridExportingArgs e)

 

{

 

 

string customHTML = "<table><tr><td><asp:Image ID='Image1' runat='server' ImageUrl='~/images/KIB_LOGO.png' AlternateText='KIB' Width='100%' /></td></tr></table>";

 

e.ExportOutput = e.ExportOutput.Replace(

"<body>", String.Format("<body>{0}", customHTML));

 

}

Will you please help me to implement the Export for PDF, CSV, WORD, EXCEL with Header of Logo and Footer of Report Info in each page.
We are in implementation time. your immediate solution will help us.

Regards,
Sheik

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Jul 2010, 04:46 PM
Hello Sheik,

The CSV format doesn't support headers and footers at all.

For ExcelML - headers and footers are supported out-of-the-box
ExcelML structure / GridExcelBuilder

For HTML Excel:
protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
{
    if (e.ExportType == ExportType.Excel)
    {
        string header = "My Header";
        string footer = "My Footer";
        string css = String.Format("<style> table @page {{ mso-header-data:\"{0}\"; mso-footer-data:\"{1}\"; }}</style>", header, footer);
        e.ExportOutput = e.ExportOutput.Replace("<head>", "<head>" + css);
    }
}

Word and PDF - You could insert text in the beginning and the end of the output but it is not possible to add headers and footers on every page as it is possible in the Excel formats.

Please note that only the PDF format can handle images.
PDF export

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Sheik Alavudeen
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or