Open Closed

Excel output changes numbers to text #9628


0
tbentley created

I'm using the latest version of AspNetZero (v9.1.0) .NetCore with angular. I am trying to export my grid using the ExportToFile used in the auditLog as a example

The Excel Spreadsheet is getting generated correctly except all my decimal values (Dollar amounts) are flagged with a warning as "The number in this cell is formatted as text or preceded by an apostrophe"

This is how it defauls so I then tried using a variety of methods to format the currency For example.

                ICellStyle currencyFmt = sheet.Workbook.CreateCellStyle();
                 currencyFmt.DataFormat = (short)7; //"($#,##0.00);($#,##0.00)"


                sheet.SetDefaultColumnStyle(5, currencyFmt);

How do I have amount get output as numbers into Excel so I can do computation on them

I know if I multiply the values by a cell containing a 1 that the numbers convert to a number but that is a cumbersome hack.

Thanks.... Terry


4 Answer(s)
  • 0
    ismcagdas created
    Support Team

    Hi @tbentley

    Could you also share the culture your are using in yoru app ?

    Thanks,

  • 0
    tbentley created

    I am just selecting the US flag and allowing the defaults. I changed the language to the English flag and got the same thing. The Dto that I pass to the "ExportToFile" has all the numberic fields defined as decimal or decimal?

  • 0
    ismcagdas created
    Support Team

    Hi,

    It seems like NPOI library has some problems about this https://github.com/dotnetcore/NPOI/issues/132. You can format the text and set the cell content manually.

  • 1
    tbentley created

    Thanks. Yes, that is what I did. It was a little tedious but it works.