C# 使用EPPlus 操作excel The given key '8' was not present in the dictionary.
最开始的写法,是从前往后删除,出现错误
//ExcelWorksheet sheet = package.Workbook.Worksheets[i];
//sheet.DeleteColumn(4);//单价(未税)
//sheet.DeleteColumn(4);//单价(含税)
//sheet.DeleteColumn(8);//未税总额
//sheet.DeleteColumn(16);//目标价格
//sheet.DeleteColumn(16);//应该成本小计
//sheet.DeleteColumn(16);//目标成本小计
//sheet.DeleteColumn(16);//差额
改成从后往前删除,问题就解决了
ExcelWorksheet sheet = package.Workbook.Worksheets[i];
sheet.DeleteColumn(22);//差额
sheet.DeleteColumn(21);//目标成本小计
sheet.DeleteColumn(20);//应该成本小计
sheet.DeleteColumn(19);//目标价格
sheet.DeleteColumn(10);//未税总额
sheet.DeleteColumn(5);//单价(含税)
sheet.DeleteColumn(4);//单价(未税)