用C++设置形状或文本框的文本效果阴影
Contents
[
Hide
]
你可以为任何形状或文本框的文本效果设置阴影。请使用Shape.GetTextBody()属性,它会展示形状文本的设置并返回FontSetting对象。在访问后,请通过FontSetting.GetPresetType()属性设置阴影。该属性类型为PresetShadowType,具有几个值,部分如下:
- 偏移对角线底部右
- 偏移底部
- 偏移对角线顶部右
- 内部左
- 内部中心
- 透视对角线左上
- 透视对角线右下
以下代码片段演示了如何使用FontSetting.GetPresetType()属性为形状或文本框设置文本效果的阴影。
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Drawing;
int main()
{
Aspose::Cells::Startup();
// Output directory
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create workbook object
Workbook wb;
// Access first worksheet
Worksheet ws = wb.GetWorksheets().Get(0);
// Add text box with these dimensions
TextBox tb = ws.GetShapes().AddTextBox(2, 0, 2, 0, 100, 400);
// Set the text of the textbox
tb.SetText(u"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::OffsetBottom);
}
// Set the font color and size of the textbox
tb.GetFont().SetColor(Color::Red());
tb.GetFont().SetSize(16);
// Save the output file
wb.Save(outDir + u"outputSettingTextEffectsShadowOfShapeOrTextbox.xlsx", SaveFormat::Xlsx);
std::cout << "Text effects shadow of shape or textbox set successfully!" << std::endl;
Aspose::Cells::Cleanup();
}