I am exporting to excel from gridview. Is there any way to format the header text and wrap it in the excel ?. My export to excel code as
grdCommon.Font.Size = FontUnit.XSmall;
grdCommon.GridLines = GridLines.Both;
grdCommon.Style["font-family"] = "Arial, Helvetica, sans-serif;";
grdCommon.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
grdCommon.HeaderStyle.ForeColor = System.Drawing.Color.White;
grdCommon.HeaderStyle.BackColor = System.Drawing.Color.FromArgb(80, 124, 209);
grdCommon.HeaderStyle.Font.Size = 8;
grdCommon.HeaderStyle.Width = 30;
I tried adding as below to format the header column in excel. but the excel header doesnt gets wraped
grdCommon.HeaderRow.Style.Value = "word-break:break-all;word-wrap:break-word";
grdCommon.HeaderRow.Cells[0].Wrap = true;
and modified this method
grdCommon.HeaderRow.Style.Add("background-color", "#FFFFFF"); as
grdCommon.HeaderRow.Style.Add("word-wrap","true");
Any suggestions...
Here is a solution of the formating gridview header.
grdCommon.HeaderRow.CssClass = "header";
<style>
.header
{
background-color:Silver;
color:White;
}
</style>
Using header css class you can add the css properties value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With