Is it possible to ignore Excel warnings when generating spreadsheets using EPPlus?

前端 未结 4 424
余生分开走
余生分开走 2020-12-06 18:54

I\'m storing mix of numeric and non-numeric values in a single column in spreadsheet using C# and EPPlus. When I open spreadsheet with Excel it shows green triangles in the

4条回答
  •  时光说笑
    2020-12-06 18:58

    From the EPPlus documentation:

    My number formats does not work If you add numeric data as strings (like the original ExcelPackage does), Excel will treat the data as a string and it will not be formatted. Do not use the ToString method when setting numeric values.

    string s="1000"
    int i=1000;
    worksheet.Cells["A1"].Value=s; //Will not be formatted
    worksheet.Cells["A2"].Value=i; //Will be formatted
    worksheet.Cells["A1:A2"].Style.Numberformat.Format="#,##0";
    

    http://epplus.codeplex.com/wikipage?title=FAQ&referringTitle=Documentation

提交回复
热议问题