Highlight the row when exporting RadGrid to excel

4 posts, 0 answers
  1. Vitaly
    Vitaly  avatar
    68 posts
    Member since:
    Aug 2011

    Posted 08 Sep Link to this post

    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.

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 13 Sep Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vitaly
    Vitaly  avatar
    68 posts
    Member since:
    Aug 2011

    Posted 13 Sep Link to this post

    Hi,

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

    Thanks so much for your help.

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 16 Sep Link to this post

    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.
Back to Top