Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions src/EPPlus/Drawing/ExcelDrawings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1218,10 +1218,6 @@ private void AddPicture(string Name, ExcelPicture pic)
}
private void ValidatePictureFile(string Name, FileInfo ImageFile)
{
if (Worksheet is ExcelChartsheet && _drawingsList.Count > 0)
{
throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
}
if (ImageFile == null)
{
throw (new Exception("AddPicture: ImageFile can't be null"));
Expand Down Expand Up @@ -1296,10 +1292,6 @@ public ExcelChart AddChartFromTemplate(Stream crtxStream, string name)
/// <returns>The new chart</returns>
public ExcelChart AddChartFromTemplate(Stream crtxStream, string name, ExcelPivotTable pivotTableSource)
{
if (Worksheet is ExcelChartsheet && _drawingsList.Count > 0)
{
throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
}
CrtxTemplateHelper.LoadCrtx(crtxStream, out XmlDocument chartXml, out XmlDocument styleXml, out XmlDocument colorsXml, out ZipPackagePart themePart, "The crtx stream");
if (chartXml == null)
{
Expand Down Expand Up @@ -1401,10 +1393,6 @@ public ExcelShape AddShape(string Name, eShapeStyle Style)
}
internal ExcelShape AddShape(string Name, eShapeStyle Style, object container = null)
{
if (Worksheet is ExcelChartsheet && _drawingsList.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");
Expand Down Expand Up @@ -1436,11 +1424,6 @@ internal ExcelShape AddShape(string Name, eShapeStyle Style, object container =
/// <returns>The slicer drawing</returns>
public ExcelTableSlicer AddTableSlicer(ExcelTableColumn TableColumn)
{
if (Worksheet is ExcelChartsheet && _drawingsList.Count > 0)
{
throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
}

if (TableColumn.Table.AutoFilter.Columns[TableColumn.Position] == null)
{
TableColumn.Table.AutoFilter.Columns.AddValueFilterColumn(TableColumn.Position);
Expand All @@ -1464,10 +1447,6 @@ public ExcelTableSlicer AddTableSlicer(ExcelTableColumn TableColumn)
/// <returns>The slicer drawing</returns>
internal ExcelPivotTableSlicer AddPivotTableSlicer(ExcelPivotTableField Field)
{
if (Worksheet is ExcelChartsheet && _drawingsList.Count > 0)
{
throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
}
if (!string.IsNullOrEmpty(Field.Cache.Formula))
{
throw new InvalidOperationException("Can't add a slicer to a calculated field");
Expand Down Expand Up @@ -1524,10 +1503,6 @@ internal ExcelPivotTableSlicer AddPivotTableSlicer(ExcelPivotTableField Field)
/// <returns>The shape object</returns>
public ExcelShape AddShape(string Name, ExcelShape Source)
{
if (Worksheet is ExcelChartsheet && _drawingsList.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");
Expand All @@ -1554,10 +1529,6 @@ public ExcelShape AddShape(string Name, ExcelShape Source)
/// <exception cref="ArgumentException">Drawing names must be unique</exception>
public ExcelControl AddControl(string Name, eControlType ControlType)
{
if (Worksheet is ExcelChartsheet && _drawingsList.Count > 0)
{
throw new InvalidOperationException("Chart worksheets can't have more than one drawing");
}
if (_drawingNames.ContainsKey(Name))
{
throw new ArgumentException("Name already exists in the drawings collection");
Expand Down
11 changes: 11 additions & 0 deletions src/EPPlusTest/Drawing/Chart/ChartShapeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ namespace EPPlusTest.Drawing.Chart
[TestClass]
public class ChartShapeTest : TestBase
{
[TestMethod]
public void ShapeInChart()
{
using var p = OpenTemplatePackage("Cheert.xlsx");
var cheert = p.Workbook.Worksheets["Chart1"];
var chart = cheert.Drawings[0] as ExcelChartStandard;
chart.Drawings.AddShape("myshpe", eShapeStyle.ActionButtonReturn);
SaveAndCleanup(p);
}


[TestMethod]
public void ShapeInChartTest()
{
Expand Down