Gestisci Stringa Html Celle

Possibili Scenari di Utilizzo

Quando hai bisogno di impostare dati formattati per una cella specifica, puoi assegnare una stringa html alla cella. Naturalmente, puoi anche ottenere la stringa HTML della cella. Aspose.Cells offre questa funzionalità. Aspose.Cells fornisce le proprietà e i metodi seguenti per aiutarti a raggiungere i tuoi obiettivi.

Ottieni e imposta la stringa html utilizzando la libreria excel Aspose.Cells per Python

Questo esempio mostra come:

  1. Creare un workbook e aggiungere alcuni dati.
  2. Ottenere la cella specifica nella prima scheda di lavoro.
  3. Impostare una stringa HTML nella cella.
  4. Ottenere la stringa HTML della cella.
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 generato dal codice di esempio

Lo screenshot seguente mostra l’output del codice di esempio precedente.

todo:image_alt_text