我把FarPoint中所有的数据导出到Excel然后再把Excel导入到一个DataTable中,可总是不成功请教各位大侠了,帮我看看怎么回事,感激不尽
using System.Data;
using System.Data.OleDb;
using System.Data.Odbc;fpSpread1.Save(Application.StartupPath+@"\farP.xml",true); 
string strFileDir = Application.StartupPath+@"\farP.xml";
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+strFileDir+";Extended Properties='Excel 8.0;HDR=False;IMEX=1'";
OleDbConnection OleConn = new OleDbConnection(strConn);
OleConn.Open();
string sql = "SELECT * FROM [Sheet1$]";
OleDbDataAdapter OleDaExcel = new OleDbDataAdapter(sql,OleConn);
DataSet  OleDsExcle = new DataSet();
OleDaExcel.Fill(OleDsExcle,"aa");
OleConn.Close();总是在OleConn.Open();出断点,小弟在线等

解决方案 »

  1.   

    string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+strFileDir+";Extended Properties='Excel 8.0;HDR=False;IMEX=1'";改为:
    string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+strFileDir+";Extended Properties=Excel 8.0;HDR=False;IMEX=1";

    string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+strFileDir+";Extended Properties=Excel 8.0";
      

  2.   

    fpSpread1.Save(Application.StartupPath+@"\farP.xls",true); 
    string strFileDir = Application.StartupPath+@"\farP.xls";
    这两个表是excel表,不是xml表
    我用catch以后,报的错误是“外部表不是预期的格式”
      

  3.   

    我知道是excel文件啊你多了个单引号吧
    Properties='Excel 8.0;HDR=False;IMEX=1'";