
Zeeshan Abbasi
Top achievements
Rank 1
Zeeshan Abbasi
asked on 16 Jul 2010, 07:34 PM
Hi Telerik Team,
Is it possible to add header and footer in excel file while exporting from RadGrid?
Regards,
Zeeshan
Is it possible to add header and footer in excel file while exporting from RadGrid?
Regards,
Zeeshan
8 Answers, 1 is accepted
0
Hello Zeeshan,
Please try the following approach If you are using the latest version of RadControls for ASP.NET AJAX
Regards,
Daniel
the Telerik team
Please try the following approach If you are using the latest version of RadControls for ASP.NET AJAX
protected
void
Button1_Click(
object
sender, EventArgs e)
{
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
RadGrid1.MasterTableView.ExportToExcel();
}
protected
void
RadGrid1_ExcelMLExportRowCreated(
object
source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)
{
if
(e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.HeaderRow)
{
e.Worksheet.WorksheetOptions.PageSetup.PageHeaderElement.Data =
"This is a test"
;
}
}
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
0

Zeeshan Abbasi
Top achievements
Rank 1
answered on 19 Jul 2010, 02:59 PM
Hi Daniel,
Thank you for your quick reply, You mentioned in your reply that we can use the said approach with latest version of RadControls for ASP.Net AJAX. But what if we want to deploy this with DNN?
Latest Telerik dll version=2010.1.309.35 shipped with DNN 5.04.04 don't have e.Worksheet.WorksheetOptions exposed in ExcelMLExportRowCreated event?
How we can use that option with DNN as we have a separate dll of telerik for DNN?
Regards,
Zeeshan
Thank you for your quick reply, You mentioned in your reply that we can use the said approach with latest version of RadControls for ASP.Net AJAX. But what if we want to deploy this with DNN?
Latest Telerik dll version=2010.1.309.35 shipped with DNN 5.04.04 don't have e.Worksheet.WorksheetOptions exposed in ExcelMLExportRowCreated event?
How we can use that option with DNN as we have a separate dll of telerik for DNN?
Regards,
Zeeshan
0
Hello Zeeshan,
Please check this thread - there you will find a custom implementation of the desired functionality that will work for older versions of RadControls for ASP.NET AJAX.
Link to public post
Regards,
Daniel
the Telerik team
Please check this thread - there you will find a custom implementation of the desired functionality that will work for older versions of RadControls for ASP.NET AJAX.
Link to public post
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
0

LiorWinston
Top achievements
Rank 1
answered on 31 Aug 2010, 11:37 AM
Hello
I've tried using this method unsuccessfully. I have the latest version of RadControls but unfortunatly the
Furthermore - is it possible to do so to using HTML format?
Thank you very much
I've tried using this method unsuccessfully. I have the latest version of RadControls but unfortunatly the
e.Worksheet.WorksheetOptions.PageSetup.PageHeaderElement.Data =
"This is a test"
didn't work. Is there any other way of adding a header to exported excel?Furthermore - is it possible to do so to using HTML format?
Thank you very much
0
Hello LiorWinston,
I suppose you know that the header and the footer are visible only when printing (and in Print Preview mode)
As to your second question - it is possible to add header/footer text when using the HTML export although this is currently not supported out of the box.
Sample code:
Regards,
Daniel
the Telerik team
I suppose you know that the header and the footer are visible only when printing (and in Print Preview mode)
As to your second question - it is possible to add header/footer text when using the HTML export although this is currently not supported out of the box.
Sample code:
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);
}
}
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
0

Sintia
Top achievements
Rank 1
answered on 26 Jan 2011, 12:59 AM
Can someone please tell me how to add a new line return within the header. It seems like an easy task, hard to find an answer. Thanks
Here is my header:
StringBuilder sb = new StringBuilder();
.....
sb.Append(@"<style>
@page
{
mso-header-data:'&C Title on First Line /// Title on Second Line ';
}
Basically I want to include a return carriage instead of the /// noted above.
Thanks,
Sintia
Here is my header:
StringBuilder sb = new StringBuilder();
.....
sb.Append(@"<style>
@page
{
mso-header-data:'&C Title on First Line /// Title on Second Line ';
}
Basically I want to include a return carriage instead of the /// noted above.
Thanks,
Sintia
0
Hello Zeeshan,
Try the following approach:
I hope this helps.
Regards,
Daniel
the Telerik team
Try the following approach:
table @page
{
mso-header-data:
"&CMultiplication Table\000ADate\: &D\000APage &P"
;
mso-page-orientation:landscape;
}
I hope this helps.
Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Dhamodharan
Top achievements
Rank 1
answered on 21 Apr 2011, 09:14 AM
Hi,
I am using ExcelML exporting from radgrid. i am using the same code. but the header is not shown in my excelML page.
please let me know any possible ans for this problem?
Thanks in advance,
Dhamu.
I am using ExcelML exporting from radgrid. i am using the same code. but the header is not shown in my excelML page.
please let me know any possible ans for this problem?
Thanks in advance,
Dhamu.