设置形状或文本框的文本效果的阴影
Contents
[
Hide
]
您可以设置任何形状或文本框的文本效果的阴影。请使用Shape.text_body属性。它提供形状文本的设置,并返回FontSetting对象。访问后,请通过FontSetting.text_options.shadow.preset_type属性设置阴影。这个属性是PresetShadowType类型,具有多个值。其中一些是
- OFFSET_DIAGONAL_BOTTOM_RIGHT
- OFFSET_BOTTOM
- OFFSET_DIAGONAL_TOP_RIGHT
- 内侧左侧
- 内侧中心
- 透视对角线上方左侧
- 透视角朝右上方
以下代码片段演示了使用 FontSetting.text_options.shadow.preset_type 属性来设置形状或文本框的文本效果阴影。
This file contains hidden or 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
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import PresetShadowType | |
from aspose.pydrawing import Color | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Output directory | |
outputDir = RunExamples.Get_OutputDirectory() | |
# Create workbook object | |
wb = Workbook() | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Add text box with these dimensions | |
tb = ws.shapes.add_text_box(2, 0, 2, 0, 100, 400) | |
# Set the text of the textbox | |
tb.text = "This text has the following settings.\n\nText Effects > Shadow > Offset Bottom" | |
# Set all the text runs shadow to preset offset bottom | |
for i in range(len(tb.text_body)): | |
tb.text_body[i].text_options.shadow.preset_type = PresetShadowType.OFFSET_BOTTOM | |
# Set the font color and size of the textbox | |
tb.font.color = Color.red | |
tb.font.size = 16 | |
# Save the output file | |
wb.save(outputDir + "outputSettingTextEffectsShadowOfShapeOrTextbox.xlsx", SaveFormat.XLSX) |