读书人

excel.Application.Workbooks.Open疏失

发布时间: 2012-12-28 10:29:04 作者: rapoo

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

读书人网 >C#

热点推荐