前面我们介绍了如何使用 spire.presentation 添加或删除powerpoint常规图形到幻灯片,该文将详细介绍如何使用c#添加圆角矩形到幻灯片并设置圆角矩形的半径。
c#
using spire.presentation;
using spire.presentation.drawing;
using system.drawing;
namespace roundrectangle
{
class program
{
static void main(string[] args)
{
presentation presentation = new presentation();
//插入圆角矩形并设置其半径
presentation.slides[0].shapes.insertroundrectangle(0, 60, 90, 100, 200, 36);
//添加圆角矩形并设置其半径
iautoshape shape = presentation.slides[0].shapes.appendroundrectangle(260, 90, 100, 200, 80);
//设置圆角矩形的填充颜色
shape.fill.filltype = fillformattype.solid;
shape.fill.solidcolor.color = color.seagreen;
shape.shapestyle.linecolor.color = color.white;
//旋转90度
shape.rotation = 90;
//保存文档
presentation.savetofile("result.pptx", fileformat.pptx2013);
}
}
}
vb.net
imports spire.presentation
imports spire.presentation.drawing
imports system.drawing
namespace roundrectangle
class program
private shared sub main(args as string())
dim presentation as new presentation()
'插入圆角矩形并设置其半径
presentation.slides(0).shapes.insertroundrectangle(0, 60, 90, 100, 200, 36)
'添加圆角矩形并设置其半径
dim shape as iautoshape = presentation.slides(0).shapes.appendroundrectangle(260, 90, 100, 200, 80)
'设置圆角矩形的填充颜色
shape.fill.filltype = fillformattype.solid
shape.fill.solidcolor.color = color.seagreen
shape.shapestyle.linecolor.color = color.white
'旋转90度
shape.rotation = 90
'保存文档
presentation.savetofile("result.pptx", fileformat.pptx2013)
end sub
end class
end namespace
效果图: