title: Pasting excel data into a blank DataGridView - Index out of range exception
body: <p>I have an excel sheet with the following:</p>
  
  <p><img src="https://i.stack.imgur.com/8hPM1.png" alt="enter image description here"></p>
  
  <p>So, what I am trying to achieve is copy this from Excel and paste it into a blank <code>DataGridView</code> view.</p>
  
  <p>This is the code I have so far:</p>
  
  <pre><code>private void PasteClipboard(DataGridView myDataGridView)
  {
      DataObject o = (DataObject)Clipboard.GetDataObject();
      if (o.GetDataPresent(DataFormats.Text))
      {
          string[] pastedRows = Regex.Split(o.GetData(DataFormats.Text).ToString().TrimEnd("\r\n".ToCharArray()), "\r\n");
          foreach (string pastedRow in pastedRows)
          {
              string[] pastedRowCells = pastedRow.Split(new char[] { '\t' });
              using (DataGridViewRow myDataGridViewRow = new DataGridViewRow())
              {
                  for (int i = 0; i &lt; pastedRowCells.Length; i++)
                      myDataGridViewRow.Cells[i].Value = pastedRowCells[i];
  
                  myDataGridView.Rows.Add(myDataGridViewRow);
              }
          }
      }
  }
  </code></pre>
  
  <p>When the code runs, I am getting the following error:</p>
  
  <p><img src="https://i.stack.imgur.com/BfJsQ.png" alt="enter image description here"></p>
  
  <p>Am I approaching this task at hand incorrectly?</p>