用EPPlus复制/克隆Excel形状?

是否可以使用EPPlus库在Excel工作表中创build形状的复制/克隆?

我知道我可以得到一个现有的对象

var shapeExisting = ws.Drawings["ShapeName"]; 

ws是工作表对象)

和一个创造新的形状

 var shapeNew = ws.Drawings.AddShape("NewName", eShapeStyle.RtTriangle); 

但是,我无法find克隆shapeExisting

似乎没有内置的function,所以,直到我find更好的解决scheme,我将以下方法添加到EPPlus\Drawings\ExcelDrawings.cs

 public ExcelShape CloneShape(string SourceName, string TargetName) { if ( _drawingNames.ContainsKey(TargetName.ToLower())) { throw new Exception("Target name already exists in the drawings collection"); } if (!_drawingNames.ContainsKey(SourceName.ToLower())) { throw new Exception("Source shape does not exist in the drawings collection"); } ExcelShape shape = new ExcelShape(this, this._drawingsXml, (ExcelShape) this[SourceName]); shape.Name = TargetName; _drawings.Add(shape); _drawingNames.Add(TargetName.ToLower(), _drawings.Count - 1); return shape; } 

以及ExcelShape.cs这个构造函数:

 internal ExcelShape(ExcelDrawings drawings, XmlDocument DrawingsXml, ExcelShape shapeSource) : base(drawings, shapeSource._topNode.Clone(), "xdr:sp/xdr:nvSpPr/xdr:cNvPr/@name") { this.init(); XmlNode colNode = DrawingsXml.SelectSingleNode("//xdr:wsDr", NameSpaceManager); colNode.AppendChild(this._topNode); }