在形状的文本选项中指定字体的远东和拉丁名称
Contents
[
Hide
]
可能的使用场景
有时你想用远东语言字体显示文本,例如日语、中文、泰语等。Aspose.Cells 提供文本选项.FarEastName属性,可用于指定远东语言的字体名称。此外,您还可以使用指定拉丁字体名称文本选项.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-.NET | |
// Create empty workbook. | |
Workbook wb = new Workbook(); | |
// Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
// Add textbox inside the worksheet. | |
int idx = ws.TextBoxes.Add(5, 5, 50, 200); | |
Aspose.Cells.Drawing.TextBox tb = ws.TextBoxes[idx]; | |
// Set the text of the textbox. | |
tb.Text = "こんにちは世界"; | |
// Specify the Far East and Latin name of the font. | |
tb.TextOptions.LatinName = "Comic Sans MS"; | |
tb.TextOptions.FarEastName = "KaiTi"; | |
// Save the output Excel file. | |
wb.Save("outputSpecifyFarEastAndLatinNameOfFontInTextOptionsOfShape.xlsx", SaveFormat.Xlsx); |