在形状的文本选项中指定远东和拉丁文字体的名字
Contents
[
Hide
]
可能的使用场景
有时您可能需要显示远东语言字体的文本,例如日语、中文、泰语等。Aspose.Cells提供了TextOptions.FarEastName属性,可用于指定远东语言的字体名称。此外,您还可以使用TextOptions.LatinName属性指定拉丁字体的名称。
在形状的文本选项中指定远东和拉丁文字体的名字
以下示例代码创建一个文本框,并在其中添加一些日语文本。然后指定文本的拉丁字体和远东字体名称,并将工作簿保存为输出Excel文件。以下屏幕截图显示了Microsoft 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Create empty workbook. | |
Workbook wb = new Workbook(); | |
// Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Add textbox inside the worksheet. | |
int idx = ws.getTextBoxes().add(5, 5, 50, 200); | |
TextBox tb = ws.getTextBoxes().get(idx); | |
// Set the text of the textbox. | |
tb.setText("こんにちは世界"); | |
// Specify the Far East and Latin name of the font. | |
tb.getTextOptions().setLatinName("Comic Sans MS"); | |
tb.getTextOptions().setFarEastName("KaiTi"); | |
// Save the output Excel file. | |
wb.save("outputSpecifyFarEastAndLatinNameOfFontInTextOptionsOfShape.xlsx", SaveFormat.XLSX); |