Export to Excel format output data problem when remove commas

Export to Excel format output data problem when remove commas

touchlifetouchlife Posts: 4Questions: 3Answers: 0
edited December 2016 in Free community support

I followed this way https://datatables.net/extensions/buttons/examples/html5/outputFormat-function.html

and it's return all column, body from

Transaction         Amount
Withdraw Saving 1,000.00

to

Transaction Amount
<span id="ContentPlaceHolder1_GridView1_Label3_0">Withdraw Saving</span>    <span id="ContentPlaceHolder1_GridView1_Label7_0">1,000.00</span>

on export Excel

this what i tried

var buttonCommon = {
                exportOptions: {
                    format: {
                        body: function (data, column, row, node) {

                            return column === 9 ?
                                data.replace(/[,]/g, '') :
                                data;
                        }
                    }
                }
            };

            $('#<%= GridView1.ClientID %>').dataTable({
                //dom: 'Blfrtip',
                dom: "<'row'<'col-sm-6'lB><'col-sm-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",
                paging: true,
                buttons: [
                    {
                        extend: "colvis",
                        text: 'Show columns',
                        className: "btn-sm",
                        postfixButtons: ['colvisRestore'],
                        columns: ':gt(0)'
                    },
                    {
                        extend: "copy",
                        className: "btn-sm",buttonCommon
                    },

               $.extend( true, {}, buttonCommon, {

                   extend: "excelHtml5",
                   className: "btn-sm",

                   title: "TL" + tdate
               }),
                    {
                        extend: "print",
                        className: "btn-sm",
                        title: "TL" + tdate
                    }
                ],
               //--Hide Column NO
                //columnDefs: [
                //    {
                //        targets: 0,
                //        visible: false
                //    }
                //],
                "lengthMenu": [[20, 30, 40, -1], [20, 30, 40, "All"]],

                colReorder: true,
                responsive: false
            });
            document.getElementById("xcon").style.display = "block";

I don't know why it's just remove a 'Comma' on Column Amount but it's effect all column

Answers

  • allanallan Posts: 63,831Questions: 1Answers: 10,518 Site admin

    Happy to take a look at it if you post a link to a test case showing the issue.

    Allan

This discussion has been closed.