Number format with total datatable

Number format with total datatable

Yanez25Yanez25 Posts: 1Questions: 1Answers: 0
edited October 2023 in Free community support

can you help me understand how to format the numbers (amounts) when I export data to excel? If on the datatable I display them correctly, on excel they are displayed but (incorrect formatting. example: 15.405 --> 1540.5 instead of 15.405 1.663.405 --> 1663.405 instead of 1.663.405

I post the portion of datatable code where I attempt to format the amounts correctly


**buttons: [ { extend: 'excelHtml5', footer: true, className: "buttons-excel buttons-html5", text: "<img src='img/excel.png'/>", title: 'My_report', exportOptions: { format: { body: function(data, row, column, node) { var y = data.replace('.', ''); return y.replace(',', '.'); }, footer: function(data, row, column, node) { var y = data.replace('.', ''); return y.replace(',', '.'); } } } } ]**:

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    Excel does its own formatting. Ideally you want to export an unformatted number for Excel and let it do whatever formatting is needed.

    However, as Colin says, we'd need a test case to be able to help further.

    Allan

Sign In or Register to comment.