Using Built-in Styles
Contents
[
Hide
]
Aspose.Cells for Python via .NET 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.create_builtin_style 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
Python code to use built-in styles
This file contains hidden or 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
from aspose.cells import BuiltinStyleType, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
output1Path = dataDir + "Output.xlsx" | |
output2Path = dataDir + "Output.out.ods" | |
workbook = Workbook() | |
style = workbook.create_builtin_style(BuiltinStyleType.TITLE) | |
cell = workbook.worksheets[0].cells.get("A1") | |
cell.put_value("Aspose") | |
cell.set_style(style) | |
worksheet = workbook.worksheets[0] | |
worksheet.auto_fit_column(0) | |
worksheet.auto_fit_row(0) | |
workbook.save(output1Path) | |
print("File saved {0}", output1Path) | |
workbook.save(output2Path) | |
print("File saved {0}", output1Path) |