简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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