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

Highlight the row when exporting RadGrid to excel

3 Answers 49 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vitaly
Top achievements
Rank 1
Iron
Iron
Vitaly asked on 08 Sep 2016, 05:34 PM

Hi,

I have a RadGrid with a few columns:

<telerik:GridBoundColumn HeaderText="LOC" DataField="HomeLoc" UniqueName="HomeLoc" ReadOnly="True" SortExpression="HomeLoc" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="YTD HRS" DataField="TotHrs" UniqueName="TotHrs" ReadOnly="True" SortExpression="TotHrs" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
</telerik:GridBoundColumn>

When I export RadGrid to excel I need based on criteria highlight entire row in excel:

if TotHrs > 500

highlight entire row.

How it can be done.I try event ExportCellFormatting but it is not working.

protected void PSEmplGrid_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
GridDataItem item = e.Cell.Parent as GridDataItem;
if (e.FormattedColumn.UniqueName == "TotHrs")
{
e.Cell.Style["background-color"] = "Red";
}
}

 

Thank you.

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 13 Sep 2016, 12:55 PM
Hello,

Please examine the following help-topic and let us know if you need more information.
Word/Excel export (HTML-based)

Regards,
Maria Ilieva
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Vitaly
Top achievements
Rank 1
Iron
Iron
answered on 13 Sep 2016, 05:29 PM

Hi,

could you please provide me example. when I am exporting grid the row still not highlighted.

Thanks so much for your help.

0
Maria Ilieva
Telerik team
answered on 16 Sep 2016, 03:27 PM
Hi,

You can see the demo below and how the custom styles are applied for achieving the required functionality in your end:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/exporting/excel-export/defaultcs.aspx

Regards,
Maria Ilieva
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
Vitaly
Top achievements
Rank 1
Iron
Iron
Answers by
Maria Ilieva
Telerik team
Vitaly
Top achievements
Rank 1
Iron
Iron
Share this question
or