更改行或列的字体和颜色
Contents
[
Hide
]
在本主题中,我们将讨论如何更改工作表的行和列的字体和字体颜色。这是Aspose.Cells.GridDesktop提供的基本级别格式化功能,可让开发人员自定义其工作表的视图,使其更具表现力。
更改列的字体和颜色
要使用Aspose.Cells.GridDesktop更改列的字体和颜色,请按照以下步骤操作:
- 访问任何所需的工作表
- 访问要更改其字体和颜色的列
- 创建自定义的字体
- 将列的字体设置为自定义的字体
- 最后,将列的字体颜色设置为任意所需的颜色
//Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
//Accessing the first column of the worksheet
GridColumn column = sheet.Columns[0];
//Creating a customized Font object
Font font = new Font("Arial", 10, FontStyle.Bold);
//Setting the font of the column to the customized Font object
column.SetFont(font);
//Setting the font color of the column to Blue
column.SetFontColor(Color.Blue);
更改行的字体和颜色
- 访问任何所需的工作表
- 访问要更改其字体和颜色的行
- 创建自定义的字体
- 将行的字体设置为自定义的字体
- 最后,将行的字体颜色设置为任意所需的颜色
//Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
//Accessing the first row of the worksheet
GridRow row = sheet.Rows[0];
//Creating a customized Font object
Font font = new Font("Arial", 10, FontStyle.Underline);
//Setting the font of the column to the customized Font object
row.SetFont(font);
//Setting the font color of the column to Green
row.SetFontColor(Color.Green);