title: How to import an excel file to DataGridView in C#
body: <p>I'am working for importing an excel file into my <code>DataGridView</code>. But how do I import excel file with selected rows and column in my <code>DataGridView</code>? I have only code for load the whole excel file to my <code>DataGridView</code>, I'm new in C# </p>
  
  <p>I have open dialogfile and search for the excel file, let's say my data starts in <code>C:34,D:34</code> and <code>E:34</code> in one column or data that have a EmploayeeName and select the top 24 rows and load it to my <code>DataGridView</code>. </p>
  
  <p>Thank you in advance for giving a hand! 
  This is the only stuff that I have :(</p>
  
  <pre><code>private void OpenFile_Click(object sender, EventArgs e)
  {
      OpenFileDialog fdlg = new OpenFileDialog();
      fdlg.Title = "Select file";
      fdlg.InitialDirectory = @"c:\";
      fdlg.FileName = txtFileName.Text;
      fdlg.Filter = "Excel Sheet(*.xlsx)|*.xlsx|All Files(*.*)|*.*";
      fdlg.FilterIndex = 1;
      fdlg.RestoreDirectory = true;
      if (fdlg.ShowDialog() == DialogResult.OK)
      {
          path = textBox1.Text;
          txtFileName.Text = fdlg.FileName;
  
          Application.DoEvents();
      }
  }
  
  private void LoadExcel_Click(object sender, EventArgs e)
  {
      System.Data.OleDb.OleDbConnection MyConnection;
      System.Data.DataSet DtSet;
      System.Data.OleDb.OleDbDataAdapter MyCommand;
      MyConnection = new System.Data.OleDb.OleDbConnection(@"provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\csharp.net-informations.xls';Extended Properties=Excel 8.0;");
      MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection);
      MyCommand.TableMappings.Add("Table", "Net-informations.com");
      DtSet = new System.Data.DataSet();
      MyCommand.Fill(DtSet);
      dgrdReciver.DataSource = DtSet.Tables[0];
      MyConnection.Close();
  }
  </code></pre>