无法使用EPPLUS复制包含图表的工作表

我试图复制包含图表的工作表,但是当我尝试这样做时,我的代码激发了“与指定的id的包关系不存在的源部分”exception,这是什么原因呢? *如果我从模板中删除图表,一切工作正常。

这是我的代码:

public void GenerateFromTemplate(DirectoryInfo outputPath, FileInfo templateFile, string newFileName, List<Dictionary<string, string>> cellDataList) { try { using (ExcelPackage p = new ExcelPackage(templateFile, true)) { bool first = true; foreach (Dictionary<string, string> cellData in cellDataList) { Logger.LogInfo("Adding new Sheet..."); ExcelWorksheet currentWorkSheet; if (first) { currentWorkSheet = p.Workbook.Worksheets[1]; first = false; } else { currentWorkSheet = p.Workbook.Worksheets.Copy("Ticker", "Ticker" + p.Workbook.Worksheets.Count); } foreach (KeyValuePair<string, string> cell in cellData) { Logger.LogInfo(cell.Key + "cell value set to" + cell.Value); currentWorkSheet.Cells[cell.Key].Value = cell.Value; } } Byte[] bin = p.GetAsByteArray(); string file = outputPath + newFileName; Logger.LogInfo("Writing Excel File to " + file); File.WriteAllBytes(file, bin); Logger.LogInfo("Writing Done"); } } catch (Exception ex) { Logger.LogError(ex); } } 

问候!