您好,
我们找到了一个把Shape保存为bmp图像的work around方法,示例代码如下。
该示例将Spread中的一个命名为“multiside1”的多边形shape保存为一个bmp图像。
private void button1_Click(object sender, EventArgs e)
{
//get one of the original shape in the Spread control
MultiSideShape shape1 = this.fpSpread1.ActiveSheet.GetShape("multiside1") as MultiSideShape;
if (shape1 == null)
return;
//Create a new shape from the original shape, set its location to Point(0, 0)
MultiSideShape shape2 = new MultiSideShape(shape1);
shape2.Location = new Point(0, 0);
//Create a new Bitmap for drawing the shape
Bitmap bitMap = new Bitmap(shape2.Width + 5, shape2.Height + 5);
//Draw the shape to the Bitmap
Graphics g = Graphics.FromImage(bitMap);
Rectangle rect = new Rectangle(0, 0, shape2.Width, shape2.Height);
shape2.OnPaintBackground(g, rect);
shape2.OnPaint(g, rect);
//save the Bitmap as a bmp file
bitMap.Save(@"C:\test\shape1.bmp");
} |