Ajout de texte enrichi HTML dans la cellule
Aspose.Cells pour Python via .NET prend en charge la conversion de HTML orienté Microsoft Excel en format XLS/XLSX. Cela signifie que le HTML généré par Microsoft Excel peut être converti en format XLS/XLSX en utilisant Aspose.Cells pour Python via .NET.
De même, s’il y a un HTML simple, Aspose.Cells pour Python via .NET peut le convertir en texte enrichi HTML. Aspose.Cells pour Python via .NET fournit la propriété Cell.html_string qui peut prendre un HTML simple et le convertir en texte de cellule formaté.
L’exemple de code ci-dessous vous montre comment ajouter du texte enrichi HTML dans la cellule. Veuillez consulter la capture d’écran du fichier Excel de sortie.
from aspose.cells import 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(".") | |
workbook = Workbook() | |
worksheet = workbook.worksheets[0] | |
cell = worksheet.cells.get("A1") | |
cell.html_string = "<Font Style=\"FONT-WEIGHT: bold;FONT-STYLE: italic;TEXT-DECORATION: underline;FONT-FAMILY: Arial;FONT-SIZE: 11pt;COLOR: #ff0000;\">This is simple HTML formatted text.</Font>" | |
workbook.save(dataDir + "output_out.xlsx") |