ahmedwalid05 / FastExcel

Fast Excel Reading and Writing in .Net
MIT License
335 stars 98 forks source link

The program is looping when I use existingHeadingRows #80

Open tuandomvn opened 8 months ago

tuandomvn commented 8 months ago

I am trying to use your nuget and its really fast. However I have 1 issue when trying to maintain the header in exel template so I put value to existingHeadingRows The below code that I am using

using (FastExcel.FastExcel fastExcel = new FastExcel.FastExcel(new FileInfo("myworkbook.xlsx"), new FileInfo("Output.xlsx")))
{
    var table = new DataTable();
    table.Columns.Add("Product", typeof(string));
    table.Columns.Add("Variety1", typeof(decimal));
    table.Columns.Add("Variety2", typeof(decimal));
    table.Columns.Add("Variety3", typeof(decimal));
    table.Columns.Add("Variety4", typeof(decimal));

    for (int columnNumber = 1; columnNumber < 13; columnNumber++)
    {
        table.Rows.Add("Product 1", 10, 12, 14, 45);
    }

    worksheet.PopulateRowsFromDataTable(table, 5);

    fastExcel.Write(worksheet, "MySheet", 5);
}

I also attach my sample code ConsoleApp2_FastExel.zip

Can you please have a look? Thank you.