在形状的文本选项中指定远东和拉丁文字体的名字

可能的使用场景

有时您可能需要显示远东语言字体的文本,例如日语、中文、泰语等。Aspose.Cells提供了TextOptions.FarEastName属性,可用于指定远东语言的字体名称。此外,您还可以使用TextOptions.LatinName属性指定拉丁字体的名称。

在形状的文本选项中指定远东和拉丁文字体的名字

以下示例代码创建一个文本框,并在其中添加一些日文文本。 然后指定文本的拉丁文和远东字体名称,并将工作簿保存为 output Excel file。 以下屏幕截图显示了 Microsoft Excel 中输出文本框的拉丁文和远东字体名称。

todo:image_alt_text

示例代码

// 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);