private void button3_Click(object sender, EventArgs e) { try { OleDbCommand cmd = new OleDbCommand(); string query = null; connect = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; Data Source='c:\\mydemo.xlsx';Extended properties=Excel 8.0;"); connect.Open(); cmd.Connection = connect; query = "Insert into [Sheet1$] (software_name,versions,keys) values('" + txtSNmae.Text + "','" + txtVersion.Text + "','" + txtKey.Text + "')"; cmd.CommandText = query; cmd.ExecuteNonQuery(); connect.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }
*xlsx
connect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=c:\mydemo.xlsx;Extended properties='Excel 12.0;HDR=YES';");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)