首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

excel.Application.Workbooks.Open疏失

2012-12-28 
excel.Application.Workbooks.Open出错从网上找的代码:编译的时候报:”open方法没有采用 14 个参数重载“请

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或者多写了excel.Application.Workbooks.Open疏失
[解决办法]
Open()方法是15个参数啊。再加个Nothing

热点排行