通过使用 HTML 设置 Cell 值来显示项目符号
Contents
[
Hide
]
Aspose.Cells 现在支持显示带有 HTML 代码的项目符号。本文将说明如何通过使用 HTML 设置单元格值来显示项目符号。我们将使用Cell.setHtmlString()使用我们的 HTML 设置单元格值的属性。
通过使用 HTML 设置 Cell 值来显示项目符号
以下代码使用 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(DisplayBullets.class); | |
//Create workbook object | |
Workbook workbook = new Workbook(); | |
//Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Access cell A1 | |
Cell 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>"); | |
//Save the workbook | |
workbook.save(dataDir + "output.xlsx"); |
输出
以下屏幕截图显示了上述示例代码的输出。