Manage Cells Html String
Possible Usage Scenarios
When you need to set styled data for specific Cell, you can assign a html string to the Cell. Of course, you can also obtain the HTML string of the cell. Aspose.Cells offers this feature. Aspose.Cells provides the following properties and methods to help you achieve your goals.
Get and set html string using Aspose.Cells for Python excel library
This example shows how to:
- Create a workbook and add some data.
- Get the specific Cell in the first worksheet.
- Set html string to the Cell.
- Get html string of the Cell.
from aspose.cells import Workbook | |
# Instantiating an Workbook object | |
workbook = Workbook() | |
# Obtaining the reference of the newly added worksheet | |
ws = workbook.worksheets[0] | |
cells = ws.cells | |
# Setting the value to the cells | |
cell = cells.get("A1") | |
cell.put_value("Fruit") | |
cell = cells.get("B1") | |
cell.put_value("Count") | |
cell = cells.get("C1") | |
cell.put_value("Price") | |
cell = cells.get("A2") | |
cell.put_value("Apple") | |
cell = cells.get("A3") | |
cell.put_value("Mango") | |
cell = cells.get("A4") | |
cell.put_value("Blackberry") | |
cell = cells.get("A5") | |
cell.put_value("Cherry") | |
c3 = cells.get("C3") | |
# set html string for C3 cell. | |
c3.html_string = "<b>test bold</b>" | |
c4 = cells.get("C4") | |
# set html string for C4 cell. | |
c4.html_string = "<i>test italic</i>" | |
# get the html string of specific cell. | |
print(c3.html_string) | |
print(c4.html_string) |
Output generated by the sample code
The following screenshot shows the output of the above sample code.