Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Apply the superscript effect by setting the Style.font object’s is_superscript property to true. To apply subscript, set the Style.font object’s is_subscript property to true.
The following code examples show how to apply super and subscript to text.
| from aspose.cells import SaveFormat, Workbook | |
| from os import os, path | |
| # The path to the documents directory. | |
| dataDir = "./" | |
| # Create directory if it is not already present. | |
| IsExists = path.isdir(dataDir) | |
| if notIsExists: | |
| os.makedirs(dataDir) | |
| # Instantiating a Workbook object | |
| workbook = Workbook() | |
| # Adding a new worksheet to the Excel object | |
| workbook.worksheets.add() | |
| # Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet = workbook.worksheets[0] | |
| # Accessing the "A1" cell from the worksheet | |
| cell = worksheet.cells.get("A1") | |
| # Adding some value to the "A1" cell | |
| cell.put_value("Hello") | |
| # Setting the font Superscript | |
| style = cell.get_style() | |
| style.font.is_superscript = True | |
| cell.set_style(style) | |
| # Saving the Excel file | |
| workbook.save(dataDir + "Superscript.out.xls", SaveFormat.AUTO) |
| from aspose.cells import SaveFormat, Workbook | |
| from os import os, path | |
| # The path to the documents directory. | |
| dataDir = "./" | |
| # Create directory if it is not already present. | |
| IsExists = path.isdir(dataDir) | |
| if notIsExists: | |
| os.makedirs(dataDir) | |
| # Instantiating a Workbook object | |
| workbook = Workbook() | |
| # Adding a new worksheet to the Excel object | |
| workbook.worksheets.add() | |
| # Obtaining the reference of the newly added worksheet by passing its sheet index | |
| worksheet = workbook.worksheets[0] | |
| # Accessing the "A1" cell from the worksheet | |
| cell = worksheet.cells.get("A1") | |
| # Adding some value to the "A1" cell | |
| cell.put_value("Hello") | |
| # Setting the font Subscript | |
| style = cell.get_style() | |
| style.font.is_subscript = True | |
| cell.set_style(style) | |
| # Saving the Excel file | |
| workbook.save(dataDir + "Subscript.out.xls", SaveFormat.AUTO) |
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.