title: Reading excel file in c#.net cell by cell
body: <p>I'm new to <code>c#.net</code></p>
  
  <p>I have excel sheet and I want to import into <code>database</code>.</p>
  
  <p>I want to read it cell by cell and want to insert value in <code>database</code>.</p>
  
  <pre><code>this.openFileDialog1.FileName = "*.xls";
              DialogResult dr = this.openFileDialog1.ShowDialog();
              if (dr == System.Windows.Forms.DialogResult.OK)
              {
                  string path = openFileDialog1.FileName;
                  string connectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=no;IMEX=1;""", openFileDialog1.FileName);
                  string query = String.Format("select * from [{0}$]", "Sheet3");
  
                  OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
  
                  DataSet dataSet = new DataSet();
                  dataAdapter.Fill(dataSet);
                  dataGridView1.DataSource = dataSet.Tables[0];
  </code></pre>