} private void button2_Click(object sender, EventArgs e) { string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); path = Path.Combine(path, "MINERALOGIA.xlsm"); string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "C:\\Users\\Daniel\\Desktop\\MINERALOGIA.xlsm" + ";Extended Properties=\"Excel 12.0 Xml;HDR=NO;ImpoertMixedTypes=Text;TypeGuessRows=0\";"; OleDbConnection conn = new OleDbConnection(ConnectionString); DataSet ds = new DataSet(); DataTable dt1 = ds.Tables.Add("set1"); using (OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Entrada$A1:Q1];", conn)) { adapter.Fill(dt1); } DataTable dt2 = ds.Tables.Add("set2"); using (OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Entrada$A2:Q2];", conn)) { adapter.Fill(dt2); } try { dataGridView1.AllowUserToAddRows = false; dataGridView1.ReadOnly = true; conn.Open(); dataGridView1.DataSource = ds.Tables[0]; dt2 = ds.Tables[0]; dt2.Rows.Add(ds.Tables[1]); dt2.AcceptChanges(); catch(Exception ex) { MessageBox.Show(ex.ToString()); } finally { conn.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)