当前位置:编程学习 > C#/ASP.NET >>

C#2005 如何打开microsoft office excel 2007

引用的COM组件是 Microsoft Excel 12.0 Object Library
              Microsoft Office 12.0 Object Library

将指定的2007 Excel文件打开,填充到DataSet中;

     DataSet ds = new DataSet();
     string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ;Persist Security Info=False; Data Source = " + fileName + ";Extended      Properties=Excel 8.0";
                OleDbConnection oConn = new OleDbConnection(strCon);
                string strCom = " SELECT * FROM [Sheet1$]";
                OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, oConn);                
                myCommand.Fill(ds);
                oConn.Close();

//会抛出异常“外部表不是预期的格式”
用打开数据库的方式打开2007 Excel文件 需要怎么改写?
  --------------------编程问答-------------------- mark
--------------------编程问答-------------------- up --------------------编程问答-------------------- UP...... --------------------编程问答-------------------- 呵呵,先把Excel文档保存为1997-2003的.xls试试看,再确定问题~ --------------------编程问答-------------------- CSDN网页上不是说过2007不符合行业标准么
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,