Using Built-in Styles
Contents
[
Hide
]
Aspose.Cells provides a vast collection of re-usable styles to format a cell in spreadsheet document. We can use built-in styles in our workbook and also create custom styles.
How to use Built-in Styles
The method Workbook.CreateBuiltinStyle and the enumeration BuiltinStyleType make it convenient to use built-in styles. Here is a list of all possible built-in styles:
- TWENTY_PERCENT_ACCENT_1
- TWENTY_PERCENT_ACCENT_2
- TWENTY_PERCENT_ACCENT_3
- TWENTY_PERCENT_ACCENT_4
- TWENTY_PERCENT_ACCENT_5
- TWENTY_PERCENT_ACCENT_6
- FORTY_PERCENT_ACCENT_1
- FORTY_PERCENT_ACCENT_2
- FORTY_PERCENT_ACCENT_3
- FORTY_PERCENT_ACCENT_4
- FORTY_PERCENT_ACCENT_5
- FORTY_PERCENT_ACCENT_6
- SIXTY_PERCENT_ACCENT_1
- SIXTY_PERCENT_ACCENT_2
- SIXTY_PERCENT_ACCENT_3
- SIXTY_PERCENT_ACCENT_4
- SIXTY_PERCENT_ACCENT_5
- SIXTY_PERCENT_ACCENT_6
- ACCENT_1
- ACCENT_2
- ACCENT_3
- ACCENT_4
- ACCENT_5
- ACCENT_6
- BAD
- CALCULATION
- CHECK_CELL
- COMMA
- COMMA_1
- CURRENCY
- CURRENCY_1
- EXPLANATORY_TEXT
- GOOD
- HEADER_1
- HEADER_2
- HEADER_3
- HEADER_4
- HYPERLINK
- FOLLOWED_HYPERLINK
- INPUT
- LINKED_CELL
- NEUTRAL
- NORMAL
- NOTE
- OUTPUT
- PERCENT
- TITLE
- TOTAL
- WARNING_TEXT
- ROW_LEVEL
- COLUMN_LEVEL
C# code to use built-in styles
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); |