设置形状或文本框的文本效果的阴影
Contents
[
Hide
]
您可以设置任何形状或文本框的文本效果的阴影。请使用Shape.TextBody属性。它表示形状文本的设置并返回FontSettingCollection。在访问其中的FontSetting后,请通过FontSetting.getTextOptions().getShadow().setPresetType()属性设置阴影。此属性是PresetShadowType类型,具有多个值。其中一些是
设置形状或文本框的文本效果阴影
以下屏幕截图显示了使用以下示例代码生成的输出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(SettingTextEffectsShadowOfShapeOrTextbox.class) + "articles/"; | |
// Create workbook object | |
Workbook wb = new Workbook(); | |
// Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Add text box with these dimensions | |
int idx = ws.getTextBoxes().add(2, 2, 100, 400); | |
TextBox tb = ws.getTextBoxes().get(idx); | |
// Set the text of the textbox | |
tb.setText("This text has the following settings.\n\nText Effects > Shadow > Offset Bottom"); | |
// Set all the text runs shadow to preset offset bottom | |
for (int i = 0; i < tb.getTextBody().getCount(); i++) { | |
tb.getTextBody().get(i).getTextOptions().getShadow().setPresetType(PresetShadowType.OFFSET_BOTTOM); | |
} | |
// Set the font color and size of the textbox | |
tb.getFont().setColor(Color.getRed()); | |
tb.getFont().setSize(16); | |
// Save the output file | |
wb.save(dataDir + "STESOfShapeOrTextbox_out.xlsx", SaveFormat.XLSX); |