在单元格内添加 HTML 富文本
Contents
[
Hide
]
Aspose.Cells for Python via .NET支持将基于Microsoft Excel的HTML转换为XLS/XLSX格式。这意味着,由Microsoft Excel生成的HTML可以使用Aspose.Cells for Python via .NET转换回XLS/XLSX格式。
同样,如果有一些简单的HTML,Aspose.Cells for Python via .NET可以将其转换为HTML富文本。Aspose.Cells for Python via .NET提供一个Cell.html_string属性,可以接受这样的简单HTML并将其转换为格式化的单元格文本。
下面的代码示例向您展示了如何在单元格中添加HTML富文本。请查看输出Excel文件的屏幕截图。
This file contains 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 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") |