title: How do I save values from a List<string> to an Excel worksheet using EPPLus
body: <p>I'm trying to save values from a <code>List&lt;string&gt;</code> to a Excel Worksheet using EPPlus so I wrote this code:</p>
  
  <pre><code>    private void button3_Click(object sender, EventArgs e)
      {
          int value = bdCleanList.Count() / Int32.Parse(textBox7.Text);
          string bases_generadas = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bases_generadas");
  
          var package = new ExcelPackage();
  
          package.Workbook.Worksheets.Add("L1");
          ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
          worksheet.Name = "L1";
  
          int j = 2;
          int col = 1;
  
          for (int i = 1; i &lt; bdCleanList.Count(); i++)
          {
              if (i%Int32.Parse(textBox7.Text) == 0)
              {
                  package.Workbook.Worksheets.Add("L" + j);
                  worksheet = package.Workbook.Worksheets[j];
                  worksheet.Name = "L" + j;
                  j += 1;
  
                  worksheet.Cells[i, col].Value = bdCleanList[i];
              }
              else
              {
                  worksheet.Cells[i, col].Value = bdCleanList[i];
              }
          }
  
          Byte[] bin = package.GetAsByteArray();
          File.WriteAllBytes(System.IO.Path.Combine(bases_generadas, "bases_generadas_" + DateTime.Now.Ticks.ToString() + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + ".xlsx"), bin);
  
          MessageBox.Show("Se generaron un total de " + value + " bases y puede encontrarlas en la siguiente ruta: " + System.IO.Path.Combine(bases_generadas, "bases_generadas_" + DateTime.Now.Ticks.ToString() + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + ".xlsx"), "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
      }
  </code></pre>
  
  <p>In the sample I'm running <code>bdCleanList.Count()</code> has 2056 values, Int32.Parse(textBox7.Text) has 500 as value so <code>value</code> gets in this case <em>5</em>, the problem here is that values for L2, L3 ... L5 aren't saved and I don't know why. Values for first worksheet is saved fine but the rest don't, what's wrong in my code? How do I set active worksheet in order to save values on the active sheet? How do I move between worksheets?</p>