小编Sva*_*far的帖子

epplus部分已经存在

我想使用epplus excel包更新(添加另一个工作表并添加图表)现有的xlsx文件.但是,我在下面的行中出错了

var pieChart = worksheet.Drawings.AddChart("Chart1", OfficeOpenXml.Drawing.Chart.eChartType.Pie);
Run Code Online (Sandbox Code Playgroud)

错误:EPPlus.dll中发生类型为"System.InvalidOperationException"的未处理异常附加信息:部分已存在

谁能帮我?先感谢您.

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", …
Run Code Online (Sandbox Code Playgroud)

.net c# excel epplus

5
推荐指数
1
解决办法
2935
查看次数

标签 统计

.net ×1

c# ×1

epplus ×1

excel ×1