This is a migrated thread and some comments may be shown as answers.
Dynamically setting cell background color on PDF Export
1 Answer 12 Views
This is a migrated thread and some comments may be shown as answers.
Chuck
Top achievements
Rank 1
Chuck asked on 04 Oct 2018, 05:36 PM

I have a RadGrid that I set the cell background colors dynamically based on cell value but none of this formatting carries over to PDF like it does in Excel export.

an someone point me to any sources I can use to program this?

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Oct 2018, 12:38 PM
Hello Chuck,

Please review the following article on the topic: Appearance, i.e.

bool isExport = false;
protected void Button1_Click(object sender, EventArgs e)
{
    isExport = true;
    RadGrid1.MasterTableView.ExportToPdf();
}
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem && isExport)
        e.Item.Style["background-color"] = "#888888";
}

In the cases, where Rebind won't be invoked you can apply the styles directly:

protected void Button1_Click(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.Items)
        item.Style["background-color"] = "#888888";
    RadGrid1.MasterTableView.ExportToPdf();
}


Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Chuck
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or