C# 是否使用ePlus将Excel形状复制/克隆到其他工作表?

C# 是否使用ePlus将Excel形状复制/克隆到其他工作表?,c#,excel,epplus,C#,Excel,Epplus,是否可以使用EPPlus库将形状复制/克隆到其他Excel工作表 此处显示的同一Excel工作表中已存在解决方案: 但我需要复制到其他工作表的可能性(从模板到目标)。有人知道解决方法吗 提前谢谢。实际上我找到了这个问题的解决方案。 我将此代码添加到ExcelDrawings.cs文件: /// <summary> /// Add a new shape to the worksheet /// </summary> /// <para

是否可以使用EPPlus库将形状复制/克隆到其他Excel工作表

此处显示的同一Excel工作表中已存在解决方案:

但我需要复制到其他工作表的可能性(从模板到目标)。有人知道解决方法吗


提前谢谢。

实际上我找到了这个问题的解决方案。 我将此代码添加到ExcelDrawings.cs文件:

    /// <summary>
    /// Add a new shape to the worksheet
    /// </summary>
    /// <param name="Name">Name</param>
    /// <param name="Source">Source shape</param>
    /// <returns>The shape object</returns>

    public ExcelShape AddShape(string Name, ExcelShape Source)
    {
        if (Worksheet is ExcelChartsheet && _drawings.Count > 0)
        {
            throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
        }
        if (_drawingNames.ContainsKey(Name))
        {
            throw new Exception("Name already exists in the drawings collection");
        }
        XmlElement drawNode = CreateDrawingXml();
        drawNode.InnerXml = Source.TopNode.InnerXml;

        ExcelShape shape = new ExcelShape(this, drawNode);
        shape.Name = Name;
        shape.Style = Source.Style;
        _drawings.Add(shape);
        _drawingNames.Add(Name, _drawings.Count - 1);
        return shape;
    }
//
///将新形状添加到工作表中
/// 
///名字
///源形状
///形状对象
公共ExcelShape AddShape(字符串名称,ExcelShape源)
{
如果(工作表为ExcelChartsheet&&U drawings.Count>0)
{
抛出新的InvalidOperationException(“图表工作表不能有多个图形”);
}
如果(_drawingNames.ContainsKey(名称))
{
抛出新异常(“图形集合中已存在名称”);
}
XmlElement drawNode=CreateDrawingXml();
drawNode.InnerXml=Source.TopNode.InnerXml;
ExcelShape=新的ExcelShape(此为drawNode);
shape.Name=名称;
shape.Style=Source.Style;
_图纸。添加(形状);
_drawingNames.Add(名称,_drawings.Count-1);
返回形状;
}