更改 Cell 的字体和颜色

更改 Cell 的字体和颜色

要使用 Aspose.Cells.GridDesktop 更改单元格的字体和颜色,请按照以下步骤操作:

  • 访问任何想要的工作表
  • 访问一个Cell要更改其字体和颜色
  • 创建自定义字体
  • 设置字体Cell到定制的
  • 最后,设置字体颜色Cell任何想要的颜色
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Accessing a cell using its name
GridCell cell = sheet.Cells["A1"];
// Creating a customized Font object
Font font = new Font("Arial", 10, FontStyle.Bold);
// Setting the font of the cell to the customized Font object
cell.SetFont(font);
// Setting the font color of the cell to Blue
cell.SetFontColor(Color.Blue);