テキストオプションのフォントの遠隔地およびラテン名を指定する
Contents
[
Hide
]
可能な使用シナリオ
時々、日本語、中国語、タイ語などの遠隔地の言語フォントでテキストを表示したい場合があります。Aspose.CellsはTextOptions.FarEastName プロパティを提供し、遠隔地の言語のフォント名を指定するために使用できます。また、TextOptions.LatinName プロパティを使用してラテンのフォント名を指定できます。
テキストオプションのフォントの遠隔地およびラテン名を指定する
次のサンプルコードは、テキストボックスを作成し、いくつかの日本語のテキストを追加します。その後、テキストのラテンと遠隔地のフォント名を指定し、ワークブックをoutput Excel fileとして保存します。次のスクリーンショットは、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); |