AddFreeFloatingShape

ShapeCollection.AddFreeFloatingShape method

向工作表添加自由浮动形状。仅适用于线条/图像形状。

public Shape AddFreeFloatingShape(MsoDrawingType type, int top, int left, int height, int width, 
    byte[] imageData, bool isOriginalSize)
范围类型描述
typeMsoDrawingType形状类型。
topInt32表示形状与工作表顶行的垂直偏移,以像素为单位。
leftInt32表示形状与工作表左列的水平偏移,以像素为单位。
heightInt32表示 LineShape 的高度,以像素为单位。
widthInt32表示 LineShape 的宽度,以像素为单位。
imageDataByte[]图片数据,仅适用于图片。
isOriginalSizeBoolean如果形状是图像,形状是否使用原始大小。

例子


[C#]
//添加一行
Shape floatingShape_Line = shapes.AddFreeFloatingShape(MsoDrawingType.Line, 100, 100, 100, 50, null, false);
//添加图片
byte[] imageData = null;
using(FileStream fs = new FileStream("image.jpg", FileMode.Open))
{
    int len = (int)fs.Length;
    imageData = new byte[len];
    fs.Read(imageData, 0, len);
}
Shape floatingShape_Picture = shapes.AddFreeFloatingShape(MsoDrawingType.Picture, 200, 100, 100, 50, imageData, false);

也可以看看