我使用 excel 库 dll 将大数据导出到 excel 但无法将字体大小设置为粗体并且无法在 excel 中实现边框。我该如何解决这个问题?
最佳答案
例如,如果您有如下所示的导出按钮:-
<asp:Button ID="Button1" runat="server" Text="Export" CommandName="Export" OnClick="btnExport_Click" />
下面的代码会将 EmployeeID
标题的大小更改为 20pt
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName =="Export")
{
GridHeaderItem HeaderItem = (GridHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0];
HeaderItem["EmployeeID"].Style["font-size"] = "20pt";
}
}
与您可以编辑的方式相同,每一行都使用
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName =="Export")
{
GridDataItem dataitem = e.Item as GridDataItem;
item["Name"].Font.Size=FontUnit.Large; //You can also change the unit to pixel too.
}
}
上述代码中,Name为待格式化的文本列。
关于c# - 如何使用 excellibrary.dll 设置 excel 单元格的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37991802/