使用EPPlus 删除excel中某一个sheet中的几列的时候,出现了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);//单价(未税)