5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 13 Jul 2009, 01:13 PM
Hi Carl,
I am not quite sure about your scenario. I guess you are using CommandItemTemplate and want to prevent that when exporting. When setting ExportOnlyData property to True, only data will be exported. I tried the below code and it is exporting the column header as the first row of the exported .xls file. Give a try with this code and see whether it is working as expected.
C#:
Thanks,
Princy.
I am not quite sure about your scenario. I guess you are using CommandItemTemplate and want to prevent that when exporting. When setting ExportOnlyData property to True, only data will be exported. I tried the below code and it is exporting the column header as the first row of the exported .xls file. Give a try with this code and see whether it is working as expected.
C#:
protected void Button1_Click(object sender, EventArgs e) |
{ |
RadGrid1.ExportSettings.ExportOnlyData = true; |
RadGrid1.ExportSettings.OpenInNewWindow = true; |
RadGrid1.MasterTableView.ExportToExcel(); |
} |
Thanks,
Princy.
0
Hello Carl,
Actually the column headers are displayed exactly on the first row. You could try this on your end by using our online demos:
MS Excel/MS Word/CSV
Let me know if I'm missing something.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Actually the column headers are displayed exactly on the first row. You could try this on your end by using our online demos:
MS Excel/MS Word/CSV
Let me know if I'm missing something.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Carl
Top achievements
Rank 1
answered on 14 Jul 2009, 12:09 PM
Good morning all.
Here is what I have at the moment. I'm using 2009.1.402.20 build.
When I export, I don't have column headers like in the example provided. So I'm not sure what is causing the ommision. The examples provided in the demo definitely do export the column headers. But mine don't.
Thanks.
<telerik:RadGrid ID="rgridSales" runat="server" Visible="false" |
OnNeedDataSource="rgridSales_NeedDataSource" AutoGenerateColumns="false" width="99%" |
Skin="Default" AllowSorting="true"> |
<MasterTableView> |
<Columns> |
<telerik:GridBoundColumn DataField="OrderDate" DataType="System.DateTime" HeaderText="Order Date" /> |
<telerik:GridBoundColumn DataField="AmazonOrderID" HeaderText="Amz. Order ID" /> |
<telerik:GridBoundColumn DataField="Quantity" HeaderText="Qty" /> |
<telerik:GridBoundColumn DataField="SKU" HeaderText="SKU" /> |
<telerik:GridBoundColumn DataField="ItemPrice" HeaderText="Amz. Price" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="shipping" HeaderText="Amz. Shipping" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="orderTotal" HeaderText="Order Total" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="Commission" HeaderText="Amz. Commission" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="ProductCost" HeaderText="Cost" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="ShippingCost" HeaderText="Shipping" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="PONumber" HeaderText="PO Number" /> |
<telerik:GridBoundColumn DataField="POAmount" HeaderText="PO Amt." DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="POProfit" HeaderText="PO Profit" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
<telerik:GridBoundColumn DataField="CostProfit" HeaderText="Cost Profit" DataFormatString="{0:C2}" ItemStyle-CssClass="money" HeaderStyle-HorizontalAlign="Right" /> |
</Columns> |
</MasterTableView> |
<PagerStyle Position="bottom" Mode="NextPrevAndNumeric" /> |
</telerik:RadGrid> |
protected void btnExcel_Click(object sender, System.EventArgs e) |
{ |
ConfigureExport(); |
rgridSales.MasterTableView.ExportToExcel(); |
} |
public void ConfigureExport() |
{ |
rgridSales.ExportSettings.FileName = "SITB_SalesReport_" + ddlVendors.Text.Replace(" ", ""); |
rgridSales.ExportSettings.ExportOnlyData = true; |
rgridSales.ExportSettings.IgnorePaging = true; |
rgridSales.ExportSettings.OpenInNewWindow = true; |
} |
0
Carl
Top achievements
Rank 1
answered on 15 Jul 2009, 02:10 PM
Does anyone have any input on this? I'm sure I'm missing something obvious, but just not seeing it.
Thanks.
0
Accepted
Hello Carl,
Try the following code:
The headers won't be exported if RadGrid is not visible. To avoid this behavior, you could use the aforementioned code-snippet. Note that when using this approach RadGrid will be visible in the output file but will remain invisible on the page.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Try the following code:
protected void button1_Click(object sender, EventArgs e) |
{ |
RadGrid1.Visible = true; |
RadGrid1.Rebind(); |
RadGrid1.MasterTableView.ExportToExcel(); |
} |
The headers won't be exported if RadGrid is not visible. To avoid this behavior, you could use the aforementioned code-snippet. Note that when using this approach RadGrid will be visible in the output file but will remain invisible on the page.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.