Formula not calculating with EPPLUS

前端 未结 2 1009
不思量自难忘°
不思量自难忘° 2021-01-27 10:13

I would like to transfer a Datatableto excel and calculate a sum. For this I\'m using epplus. Here is my code:

Sheet.Cells[\"A1\"].LoadFromDataTable         


        
2条回答
  •  失恋的感觉
    2021-01-27 10:49

    After searching long time it seems that epplus ignores the datatype if I use .LoadFromDataTable and write every value as string. So I have to parse every value to double and write it back into the cells. After that everything is running fine.

    double ZahlAlsText;
            for (int i = 2; i < totalCols; i++) 'columns
            {
                for (int y = 2; y <= letztezeile + 1; y++) 'rows
                {
                    ZahlAlsText = double.Parse(range[y, i].Value.ToString());
                    range[y, i].Style.Numberformat.Format = "#,##0.00";
                    range[y, i].Value = ZahlAlsText;
                }
            }
    

提交回复
热议问题