Formula not calculating with EPPLUS

前端 未结 2 1008
不思量自难忘°
不思量自难忘° 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;
                }
            }
    
    0 讨论(0)
  • 2021-01-27 11:04

    You should change "SUMME" to "SUM", localized formula names is handled by the Excel GUI. The underlying xml (same as Excel produces) assumes that the formula names are in english.

    From EPPlus Formula calc documentation:

    • Don't use localized function names. Only english names (such as SUM, IF, VLOOKUP, etc) are supported.
    • Don't use semicolon as a separator between function arguments. Only comma is supported.
    • Don't add the leading = sign in your formula. "=SUM(A1:A2)" is wrong, "SUM(A1:A2)" is correct
    0 讨论(0)
提交回复
热议问题