简体   繁体   English

如何使用excellibrary.dll设置excel单元格的字体大小

[英]how to set font size of excel cells using excellibrary.dll

我使用excel库DLL将大数据导出到Excel,但无法将字体大小设置为粗体,并且无法在excel中实现边框。如何解决此问题?

For example if you have the export button like below :- 例如,如果您有如下导出按钮: -

<asp:Button ID="Button1" runat="server" Text="Export" CommandName="Export" OnClick="btnExport_Click" />

The below code will change the size of EmployeeID heading to 20pt 以下代码会将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";
     }
 }

The same way you can edit, each of the rows using 您可以使用相同的方式编辑每个行

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.
         }
     }

In the above code, Name is a text column to be formatted. 在上面的代码中,Name是要格式化的文本列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM