Esempio n. 1
0
        public System.Data.DataTable getDataSheet(string path, string sheet)
        {
            OleDbConnection conn = importConn.connectionExcel(path);

            System.Data.DataTable dt = new System.Data.DataTable();
            try
            {
                conn.Open();
                string           cmd     = "select * from [" + sheet + "$]";
                OleDbCommand     command = new OleDbCommand(cmd, conn);
                OleDbDataAdapter adap    = new OleDbDataAdapter(cmd, importConn.getStringConnect());
                adap.Fill(dt);
            }
            catch
            {
                MessageBox.Show("Error when read Excel file", "Warning");
            }
            finally
            {
                conn.Dispose();
                conn.Close();
            }
            return(dt);
        }
Esempio n. 2
0
 public OleDbConnection getConnect(String path)
 {
     return(exConn.connectionExcel(path));
 }