Adding HTML Rich Text inside the Cell
Aspose.Cells supports converting Microsoft Excel oriented HTML into XLS/XLSX format. It means the HTML generated by Microsoft Excel can be converted back to XLS/XLSX format using Aspose.Cells.
Similarly, if there is some simple HTML, Aspose.Cells can convert it into HTML Rich Text. Aspose.Cells provides Cell.setHtmlString(string) method which can take such a simple HTML and convert it to formatted cell text.
Below code sample shows you how to add HTML rich text inside the cell. Please see the screenshot of the output Excel file.
const path = require("path"); | |
// The path to the documents directory. | |
const dataDir = path.join(__dirname, "data"); | |
const AsposeCells = require("aspose.cells.node"); | |
const workbook = new AsposeCells.Workbook(); | |
const worksheet = workbook.getWorksheets().get(0); | |
const cell = worksheet.getCells().get("A1"); | |
cell.setHtmlString("<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"); |