zoukankan      html  css  js  c++  java
  • C#用oledb读取Excel数据

    string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + v_strExcelPath + ";Extended Properties='Excel 12.0;IMEX=1'";
    
                OleDbDataAdapter myDataAdapter = null;
                OleDbConnection conn = new OleDbConnection(strConn);
                OleDbCommand myOleDbCommand = new OleDbCommand("SELECT * FROM [" + v_strSheetName + "$]", conn);
    
                try
                {
                    conn.Open();
                    myDataAdapter = new OleDbDataAdapter(myOleDbCommand);
                    myDataAdapter.Fill(dt);
                    conn.Dispose();
                }
    


    读取Excel中的所有栏位名称:

     1 ArrayList lv_arrList = new ArrayList();
     2             string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + v_strExcelPath + ";Extended Properties='Excel 12.0;IMEX=1'";
     3             OleDbConnection conn = new OleDbConnection(strConn);
     4             try
     5             {               
     6                 conn.Open();
     7                 DataTable sheetname = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
     8                 conn.Close();
     9                 conn.Dispose();
    10                 foreach (DataRow dr in sheetname.Rows)
    11                 {
    12                     lv_arrList.Add(dr[2].ToString().Replace("$", "").Replace("'", ""));
    13                 }
    14             }
  • 相关阅读:
    p_value
    p_value
    第一次差异分析
    fdr
    rpkm&map
    rpkm&map
    s
    python数据处理小函数集合
    Jupyter Notebook 的快捷键
    自由度degree of freedom
  • 原文地址:https://www.cnblogs.com/alexzp/p/3881582.html
Copyright © 2011-2022 走看看