i am using radgrid to export data from radgrid to excel.i want the excel format with total and total should be highlighted like some colors and i am not using bound fields in radgrid .i am using column created by programmatic
(thanks )
suresh.S
11 Answers, 1 is accepted
Please examine the following help-topic and let us know if you need more information.
Word/Excel export (HTML-based)
Best 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.
I tried the code sample
| protected void RadGrid1_ExcelExportCellFormatting(object source, Telerik.Web.UI.ExcelExportCellFormattingEventArgs e) |
| { |
| GridDataItem item = e.Cell.Parent as GridDataItem; |
| if (item.ItemType == GridItemType.AlternatingItem) |
| item.Style["background-color"] = "#359AFF"; |
| else |
| item.Style["background-color"] = "#2D62FF"; |
| } |
This code-snippet is correct. so I suppose either the event handler is not wired or the export format is not HTML Excel.
ExcelML export
Word/Excel export (HTML-based)
Let me know if I'm missing something.
Best 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.
for eg. in Gird column name [Due date] Color is "Red" while i exporting excel file that "Red" color should also exported as Gird show
Please help me
Thank You
Regards
Vikas
We have different Excel formats. Which one is used in your scenario?
If you let me know how you have changed the color to Red and which format you have I will be able to provide more to the point answer.
Regards,
Daniel
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I'm Using ExcelML export
i want export color only show in Gird
for e.g due date color red so while i exporting excel due date color is red else normal color wil be exported
please find out attachment
I would recommend that you examine the following links:
ExcelML basics
Excel demo
The easiest way to translate these colors to the ExcelML file would be to use the same logic you used to style them in RadGrid. You can use the ExcelMLExportRowCreated for that purpose.
Regards,
Daniel
Telerik
Hello Daniel
Thank's For reply
I've already try ExcelMLExportRowCreated Method apply custom style
it's exported all the column color as red? I want to check if due date color red in Gird then and then only red color exported otherwise exported as normal black color
It's possible ?
please help me i'm stuck from last 2 days
There are two ways to do that:
- examine the grid item and apply the color to the ExcelML item if needed
- use the same logic you have used to determine which item need to be styled in the grid
Let me know if you have any specific question.
Regards,
Daniel
Telerik
Hello Daniel
can you provide me simple demo so i can understand there functionality?
in grid one column due date which two color red and black.
while i exporting Excel only due date color should be red otherwise date color is black
please help i'm stuck from last 1 week
Thank You
Syan
Please try the following approach:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemCreated="RadGrid1_ItemCreated" OnExcelMLWorkBookCreated="RadGrid1_ExcelMLWorkBookCreated" OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated"> <MasterTableView CommandItemDisplay="Top"> <CommandItemSettings ShowExportToExcelButton="true" /> </MasterTableView> <ExportSettings Excel-Format="ExcelML" ExportOnlyData="true"></ExportSettings></telerik:RadGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT TOP 20 * FROM [Orders]"></asp:SqlDataSource>protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem && e.Item.ItemIndex % 3 == 0) e.Item.BackColor = System.Drawing.Color.Orange;}protected void RadGrid1_ExcelMLWorkBookCreated(object sender, GridExcelMLWorkBookCreatedEventArgs e){ var table = e.WorkBook.Worksheets[0].Table; for (int ri = 1; ri < table.Rows.Count; ri++) if (RadGrid1.MasterTableView.Items[ri - 1].BackColor == System.Drawing.Color.Orange) ApplyRowStyle(table.Rows[ri], "orangeStyle");}private void ApplyRowStyle(RowElement rowElement, string styleName){ foreach (CellElement cell in rowElement.Cells) cell.StyleValue = "orangeStyle";}protected void RadGrid1_ExcelMLExportStylesCreated(object sender, GridExportExcelMLStyleCreatedArgs e){ StyleElement style = new StyleElement("orangeStyle"); style.InteriorStyle.Color = System.Drawing.Color.Orange; style.InteriorStyle.Pattern = InteriorPatternType.Solid; e.Styles.Add(style);}I hope this helps.
Regards,
Daniel
Telerik