使用内置样式
Contents
[
Hide
]
Aspose.Cells提供了一个大量的可重复使用的样式集合,用于对电子表格文档中的单元格进行格式化。我们可以在工作簿中使用内置样式,也可以创建自定义样式。
如何使用内置样式
方法 Workbook.CreateBuiltinStyle 和枚举 BuiltinStyleType 使使用内置样式变得更加方便。以下是所有可能的内置样式列表:
- 20% 强调 1
- 20% 强调 2
- 20% 强调 3
- 20% 强调 4
- 20% 强调 5
- 20% 强调 6
- 40% 强调 1
- 40% 强调 2
- 40% 强调 3
- 40% 强调 4
- 40% 强调 5
- 40% 强调 6
- 60% 强调 1
- 60% 强调 2
- 60% 强调 3
- 60% 强调 4
- 百分之六十重音_5
- 百分之六十重音_6
- 重音_1
- 重音_2
- 重音_3
- 重音_4
- 重音_5
- 重音_6
- 错误
- 计算
- 检查单元格
- 逗号
- 逗号_1
- 货币
- 货币_1
- 说明性文本
- 良好
- 表头_1
- 表头_2
- 表头_3
- 第四标题
- HYPERLINK
- 跟随的超链接
- 输入
- 链接的单元格
- 中立的
- 普通的
- 注释
- 输出
- 百分比
- 标题
- 总计
- 警告文本
- 行级
- 列级
C# 代码以使用内置样式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
string output1Path = dataDir + "Output.xlsx"; | |
string output2Path = dataDir + "Output.out.ods"; | |
Workbook workbook = new Workbook(); | |
Style style = workbook.CreateBuiltinStyle(BuiltinStyleType.Title); | |
Cell cell = workbook.Worksheets[0].Cells["A1"]; | |
cell.PutValue("Aspose"); | |
cell.SetStyle(style); | |
Worksheet worksheet = workbook.Worksheets[0]; | |
worksheet.AutoFitColumn(0); | |
worksheet.AutoFitRow(0); | |
workbook.Save(output1Path); | |
Console.WriteLine("File saved {0}", output1Path); | |
workbook.Save(output2Path); | |
Console.WriteLine("File saved {0}", output1Path); |