I want to update (add another sheet and add diagram) an existing xlsx file using expp epplus package. However, I got an error in the next line
var pieChart = worksheet.Drawings.AddChart("Chart1", OfficeOpenXml.Drawing.Chart.eChartType.Pie);
Error: An unhandled exception of type "System.InvalidOperationException" occurred in EPPlus.dll. Additional information: part already exists
Can anyone help me? Thank you in advance.
using (ExcelPackage pck = new ExcelPackage()) { using (FileStream stream = new FileStream("Report.xlsx", FileMode.Open)) { pck.Load(stream); ExcelWorksheet worksheet = pck.Workbook.Worksheets.Add("1"); var data = new List<KeyValuePair<string, int>> { new KeyValuePair<string, int>("Group A", 44613), new KeyValuePair<string, int>("Group B", 36432), new KeyValuePair<string, int>("Group C", 6324), new KeyValuePair<string, int>("Group A", 6745), new KeyValuePair<string, int>("Group B", 23434), new KeyValuePair<string, int>("Group C", 5123), new KeyValuePair<string, int>("Group A", 34545), new KeyValuePair<string, int>("Group B", 5472), new KeyValuePair<string, int>("Group C", 45637), new KeyValuePair<string, int>("Group A", 37840), new KeyValuePair<string, int>("Group B", 20827), new KeyValuePair<string, int>("Group C", 4548), };