日期:2014-05-17  浏览次数:21054 次

excel.Application.Workbooks.Open出错
从网上找的代码:
编译的时候报:”open方法没有采用 14 个参数重载“
请问该如何解决。

代码如下:
Excel.Application excel = null;
            Excel.Workbooks wbs = null;
            Excel.Workbook wb = null;
            Excel.Worksheet ws = null;
            Excel.Range range1 = null;
            object Nothing = System.Reflection.Missing.Value;

            try
            {
               excel = new Excel.Application();
               excel.UserControl = true;
               excel.DisplayAlerts = false;

               excel.Application.Workbooks.Open("E:\\1list\\6\\1.xls", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing);

               wbs = excel.Workbooks;
               wb = wbs[1];
               ws = (Excel.Worksheet)wb.Worksheets["Sheet2"];
            }
            catch (Exception ee)
            { }
------解决方案--------------------
参数不正确,是不是少写了几个Nothing或者多写了
------解决方案--------------------
Open()方法是15个参数啊。再加个Nothing