Hi Telerik Team,
Using Telerik.Web.UI.ExportInfrastructure we are generating an excel , and looking out a way to fill the cell colors , which we achieved but after filling cell colors borders getting disappeared. I tried using below code to set borders but still borders not applying
int currentRow = 1; eis.Table WS_Sample = new eis.Table("Sample"); eis.Row headerRw1 = WS_PriorAuthorization.Rows[currentRow]; headerRw1.Style.BackColor = System.Drawing.Color.Red; headerRw1.Style.BorderLeftColor = System.Drawing.Color.Green; headerRw1.Style.BorderRightColor = System.Drawing.Color.Green; //headerRw1.Cells[1, currentRow].Style.BorderLeftWidth = Unit.Pixel(35); //headerRw1.Cells[1, currentRow].Style.BorderRightWidth = Unit.Pixel(35); headerRw1.Style.BorderLeftWidth = Unit.Pixel(35); headerRw1.Style.BorderRightWidth = Unit.Pixel(35); headerRw1.Style.ForeColor = System.Drawing.Color.Black; headerRw1.Style.Font.Bold = true;
Hi Ajay,
Could you please share the markup declaration of the RadGrid along with the relevant code-behind logic so we can get a more clear overview of the case and assist you more accurately?
What export format are you currently using?
If the case is about exporting to XLSX, you can try the styling approaches listed in the Styling Columns / Rows / Cell section in our Excel-Xlsx (OOXML) Export article. As an example:
protected void RadGrid1_InfrastructureExporting(object sender, GridInfrastructureExportingEventArgs e) { //style all cells var allCells = e.ExportStructure.Tables[0].Cells; foreach (var cell in allCells) { cell.Style.BackColor = System.Drawing.Color.Coral; cell.Style.BorderLeftColor = System.Drawing.Color.Blue; cell.Style.BorderRightColor = System.Drawing.Color.Blue; } //override styles just for the header cells var rows = e.ExportStructure.Tables[0].Rows; //actual header index may vary depending on if commandItem, top pagerItem, filterItem are exported var headerCells = rows[2].Cells; foreach (var cell in headerCells) { cell.Style.BackColor = System.Drawing.Color.Red; cell.Style.BorderLeftColor = System.Drawing.Color.Green; cell.Style.BorderRightColor = System.Drawing.Color.Green; } }