Excel Button with render with numeric

Excel Button with render with numeric

rodriformigarodriformiga Posts: 47Questions: 12Answers: 0
edited July 2018 in Free community support

Hello @allan
I have a problem with excel export and render to format number.

Definitions:

  • Numeric have thousand separator .
  • We use 2 decimals with ,
  • We use render to numeric values to format correctly $.fn.dataTable.render.number(".", ",", 2)

But, when we export by excel, the decimals are ignorated for numbers bellow 1000. For example, 253,21 is exported 25321
OBS: rule 63 is applied (https://datatables.net/reference/button/excelHtml5)

See the example: http://jsfiddle.net/rodriformiga/omeb45qp/

Replies

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I'm afraid that what is happening here is that the Excel output is currently conflicting with the number renderer when used for a comma decimal place. The Excel output currently doesn't support that form of number display - it only detects and uses a period for a decimal place which is why odd things are happening here.

    It sees "123,45" as a number with a thousands separator (it doesn't actually check that it is in the correct place, just /[0-9,]/), which is why style 63 is applied.

    In the case of "91.234,56" it doesn't detect that as a number at all, so outputs it as a string.

    To get any "sensible" output from Buttons at the moment you would need to use the exportOptions' orthogonal parameter to tell it to use the raw data, rather than the rendered data: http://jsfiddle.net/omeb45qp/2/ .

    This is without question a limitation in the Buttons export for Editor and internationalisation at the moment. It is on my list!

    Allan

This discussion has been closed.