
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar
asked on 25 Aug 2009, 04:06 PM
Hi experts
I am exporting a plain excel spreadsheet with a header row, and I am already
using the 'Caption' property for the Title. But I also need to add
the Company name and address on several lines at the top of the table.
How can I achieve this?
Thanks
Clive.
I am exporting a plain excel spreadsheet with a header row, and I am already
using the 'Caption' property for the Title. But I also need to add
the Company name and address on several lines at the top of the table.
How can I achieve this?
Thanks
Clive.
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 26 Aug 2009, 04:56 AM
Hi Clive,
I would suggest you to make use of the CommandItemTemplate to display additional information on the top of the Grid.
ASPX:
Thanks
Princy
I would suggest you to make use of the CommandItemTemplate to display additional information on the top of the Grid.
ASPX:
<MasterTableView CommandItemDisplay="Top" Caption="Title" DataSourceID="SqlDataSource1" > |
<CommandItemTemplate> |
<div> |
Company Name: |
</div> |
<div> |
Place: |
</div> |
<div> |
Contact no: |
</div> |
</CommandItemTemplate> |
Thanks
Princy
0

Clive Hoggar
Top achievements
Rank 1
answered on 26 Aug 2009, 10:25 AM
Hi Prinzy
Thanks for your response.
The commanditemetemplate does not seem to get added to the file that is exported.
Only the caption makes it through. I checked the raw html in notepad and it is not there.
I have this for the grid settings:
And this in code behind...
Is this OK?
I had other stuff going on but I stripped it all out to make sure it was not interfering.
What am I missing?
Thanks
Clive
Thanks for your response.
The commanditemetemplate does not seem to get added to the file that is exported.
Only the caption makes it through. I checked the raw html in notepad and it is not there.
I have this for the grid settings:
<telerik:RadGrid ID="RadGridGenerateList" runat="server" AllowPaging="True" AllowSorting="True" |
DataSourceID="SqlDataSource1" GridLines="None" AutoGenerateColumns="False" |
OnExcelExportRowCreated="RadGrid1_ExcelExportRowCreated" Visible="true"> |
<ExportSettings ExportOnlyData="True" FileName="WinelistExport" |
IgnorePaging="True"> |
</ExportSettings> |
<MasterTableView CommandItemDisplay="Top" Caption="Title2" DataSourceID="SqlDataSource1" > |
<CommandItemTemplate> |
<div> |
Company Name: |
</div> |
<div> |
Place: |
</div> |
<div> |
Contact no: |
</div> |
</CommandItemTemplate> |
Private Sub ButtonGenExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonGenExcel.Click |
RadGridGenerateList.MasterTableView.ExportToExcel() End Sub |
Is this OK?
I had other stuff going on but I stripped it all out to make sure it was not interfering.
What am I missing?
Thanks
Clive
0

Princy
Top achievements
Rank 2
answered on 26 Aug 2009, 11:06 AM
Hi Clive,
Try setting the ExportOnlyData to false in the Export button's click event and see whether the CommandItemTemplate is getting epxorted.
CS:
Princy
Try setting the ExportOnlyData to false in the Export button's click event and see whether the CommandItemTemplate is getting epxorted.
CS:
protected void Button1_Click(object sender, EventArgs e) |
{ |
RadGrid1.ExportSettings.ExportOnlyData = false; |
RadGrid1.ExportSettings.OpenInNewWindow = true; |
RadGrid1.MasterTableView.ExportToExcel(); |
} |
Princy
0

Clive Hoggar
Top achievements
Rank 1
answered on 26 Aug 2009, 07:24 PM
Hi Prinzy
Thanks for this.
It does work, but with ExportOnlyData = false the file size is almost 2x the size,
with the other formatting stuff in there. But life is too short to fret over the extra
second download time.
Thanks
Clive
Thanks for this.
It does work, but with ExportOnlyData = false the file size is almost 2x the size,
with the other formatting stuff in there. But life is too short to fret over the extra
second download time.
Thanks
Clive
0
Hello Clive,
Try the following approach - it is not very beautiful, but it will do the trick:
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Try the following approach - it is not very beautiful, but it will do the trick:
protected void RadGrid1_GridExporting(object source, GridExportingArgs e) |
{ |
string customHeader = "<table><tr><td>CUSTOM HEADER</td></tr></table>"; |
e.ExportOutput = e.ExportOutput.Replace("<table cellspacing", customHeader + "<table cellspacing"); |
} |
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.