通过使用HTML设置单元格值显示项目符号
Contents
[
Hide
]
Aspose.Cells 支持通过 HTML 代码显示项目符号。本文将说明如何通过设置单元格值使用 HTML 来显示项目符号。我们将使用 Cell.setHtmlString(string) 方法设置带有 HTML 的单元格值。
使用 Node.js 通过设置单元格值显示项目符号的代码示例
以下代码使用HTML代码设置单元格值。运行此代码后,您将得到如下图所示的输出。
This file contains hidden or 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
const path = require("path"); | |
const AsposeCells = require("aspose.cells.node"); | |
// The path to the documents directory. | |
const dataDir = path.join(__dirname, "data"); | |
// Create workbook object | |
const workbook = new AsposeCells.Workbook(); | |
// Access first worksheet | |
const worksheet = workbook.getWorksheets().get(0); | |
// Access cell A1 | |
const cell = worksheet.getCells().get("A1"); | |
// Set the HTML string | |
cell.setHtmlString("<font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'>Text 1 </font><font style='font-family:Wingdings;font-size:8.0pt;color:#009DD9;mso-font-charset:2;'>l</font><font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'> Text 2 </font><font style='font-family:Wingdings;font-size:8.0pt;color:#009DD9;mso-font-charset:2;'>l</font><font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'> Text 3 </font><font style='font-family:Wingdings;font-size:8.0pt;color:#009DD9;mso-font-charset:2;'>l</font><font style='font-family:Arial;font-size:10pt;color:#666666;vertical-align:top;text-align:left;'> Text 4 </font>"); | |
// Auto fit the Columns | |
worksheet.autoFitColumns(); | |
// Save the workbook | |
workbook.save(path.join(dataDir, "BulletsInCells_out.xlsx")); |
示例代码生成的输出
以下截图显示了上述示例代码的输出。