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
我从gridview导出到excel。有没有办法格式化标题文本并将其包装在Excel中?我导出为excel代码为
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
我尝试添加如下格式化excel中的标题列。但是excel标题并没有被包裹起来
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...
有什么建议么...
2 个解决方案
#1
2
Here is a solution of the formating gridview header.
这是格式化gridview标头的解决方案。
grdCommon.HeaderRow.CssClass = "header";
<style>
.header
{
background-color:Silver;
color:White;
}
</style>
Using header css class you can add the css properties value.
使用header css类可以添加css属性值。
#2
0
From what I see here I think the grdcommon is an "excel" object. If not then the wrapping should be when you send the data to the excel file upon creation.
从我在这里看到的我认为grdcommon是一个“excel”对象。如果没有,那么包装应该是在创建时将数据发送到excel文件。
If it is an "Excel" object then maybe try this link: Wrap Text in excel MSDN
如果它是一个“Excel”对象,那么可以试试这个链接:在Excel MSDN中包装文本
I hope this helps because I haven't touched any interop documents so I can't tell for sure if this is related or not.
我希望这有帮助,因为我没有触及任何互操作文件,所以我无法确定这是否相关。
And I don't know where you could find these objects but I think this is a step in the right direction.
我不知道你在哪里可以找到这些物品,但我认为这是朝着正确方向迈出的一步。
I hope I helped you.
我希望我帮助过你。
#1
2
Here is a solution of the formating gridview header.
这是格式化gridview标头的解决方案。
grdCommon.HeaderRow.CssClass = "header";
<style>
.header
{
background-color:Silver;
color:White;
}
</style>
Using header css class you can add the css properties value.
使用header css类可以添加css属性值。
#2
0
From what I see here I think the grdcommon is an "excel" object. If not then the wrapping should be when you send the data to the excel file upon creation.
从我在这里看到的我认为grdcommon是一个“excel”对象。如果没有,那么包装应该是在创建时将数据发送到excel文件。
If it is an "Excel" object then maybe try this link: Wrap Text in excel MSDN
如果它是一个“Excel”对象,那么可以试试这个链接:在Excel MSDN中包装文本
I hope this helps because I haven't touched any interop documents so I can't tell for sure if this is related or not.
我希望这有帮助,因为我没有触及任何互操作文件,所以我无法确定这是否相关。
And I don't know where you could find these objects but I think this is a step in the right direction.
我不知道你在哪里可以找到这些物品,但我认为这是朝着正确方向迈出的一步。
I hope I helped you.
我希望我帮助过你。