将文本形状的文字设置为预设的WordArt样式
Contents
[
Hide
]
可能的使用场景
您可以使用Aspose.Cells为文本形状设置预设的WordArt样式。请使用FontSetting.SetWordArtStyle()或FontSettingCollection.SetWordArtStyle()方法来实现。
将文本形状的文字设置为预设的WordArt样式
以下示例代码创建一个带有文本的文本框,然后使用FontSetting.SetWordArtStyle()方法设置其文本的预设WordArt样式。这就是在Microsoft Excel中的输出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 | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(SetPresetWordArtStyle.class) + "articles/"; | |
//Create workbook object | |
Workbook wb = new Workbook(); | |
//Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Create a textbox with some text | |
int idx = ws.getTextBoxes().add(0, 0, 100, 700); | |
TextBox tb = ws.getTextBoxes().get(idx); | |
tb.setText("Aspose File Format APIs"); | |
tb.getFont().setSize(44); | |
//Sets preset WordArt style to the text of the shape. | |
ArrayList<FontSetting> aList = tb.getCharacters(); | |
FontSetting fntSetting = aList.get(0); | |
fntSetting.setWordArtStyle(PresetWordArtStyle.WORD_ART_STYLE_3); | |
//Save the workbook in xlsx format | |
wb.save(dataDir + "SetPresetWordArtStyle_out.xlsx"); |