excel to DataSet

转载 2015年11月19日 08:55:30
        private DataSet ExcelToDS(string path, string sheetName)
        {
            DataSet ds = new DataSet();
            try
            {
                string strConn = " Provider=Microsoft.Jet.OLEDB.4.0; " + " Data Source= " + path + " ; " + " Extended Properties=Excel 8.0; ";
                OleDbConnection conn = new OleDbConnection(strConn);
                string strExcel = "";
                OleDbDataAdapter myCommand = null;
                strExcel = string.Format(" select * from [{0}$] ", sheetName);
                myCommand = new OleDbDataAdapter(strExcel, strConn);
                myCommand.Fill(ds, sheetName);
                if (conn != null)
                {
                    conn.Close();
                    myCommand.Dispose();
                }
            }
            catch (Exception)
            {
                //Undo
            }
            return ds;
        }

举报

相关文章推荐

DataSet To Excel&Chart

using System;using System.Drawing;using System.Collections.Generic;using System.Text;using System.Ru...

Dataset To Excel

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

csharp: Export DataSet into Excel and import all the Excel sheets to DataSet

/// /// Export DataSet into Excel /// /// /// private void Fo...

csharp: Export DataSet into Excel and import all the Excel sheets to DataSet

/// /// Export DataSet into Excel /// /// /// private void Fo...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)