This project has moved and is read-only. For the latest updates, please go here.

Moving to next worksheet to save new cells data

Apr 27, 2013 at 6:13 PM
Edited Apr 27, 2013 at 6:13 PM
I,ve wrote this 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;

        for (int i = 1; i < 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, 1].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);
    }
In the sample I'm running bdCleanList.Count() has 2056 values, Int32.Parse(textBox7.Text) has 500 as value so value gets in this case 5, values for first worksheet is saved fine but the rest of them don't have any values, why? what's wrong in my code?