winform导出excel报'object' does not contain a definition for 'get_Range'的问题

现手上有个老项目采用.net framework3.0开发,改成4.0后,excel导出报'object' does not contain a definition for 'get_Range'的错误:

后来发现:4.0的方法调用和3.0有所不同:

3.0-3.5:  workshhet.get_Range(sh.Cells[1, 1], sh.Cells[2, 2]);

4.0-4.5:  workshhet.Range[sh.Cells[1, 1], sh.Cells[2, 2]];

参考:https://blog.csdn.net/kongwei521/article/details/27198747

原文地址:https://www.cnblogs.com/Linky008/p/12987441.html