1

I'm exporting to excel mydatatable But I need to know how to add another title or how I could write in the next row, this is the result I expect:

enter image description here

Currently this is the result that I get, but I need to add text in the next row:

enter image description here

This is the script where I am filling the title

 <script>
            $(document).ready(function () {
                $('#example').DataTable({
                    "scrollX": true,
                    dom: 'Bfrtip',
                    buttons: [{
                        extend: 'excel',
                        className: 'btn-sm btn-flat',
                        titleAttr: 'Export in Excel',
                        text: 'Exportar a Excel',

                        filename: 'PLANILLA PRODUCCION',
                        title: 'Planilla Produccion' ,


                    }],
                                            dom: "<'row'<'col-md-3'l><'col-md-6 text-center'B><'col-md-3'f>>" +
                               "<'row'<'col-md-12'tr>>" +
                               "<'row'<'col-md-5'i><'col-md-7'p>>",
                drawCallback: function (settings) {
                    if (!$('.datatable').parent().hasClass('table-responsive')) {
                        $('.datatable').wrap("<div class='table-responsive'></div>");
                    }
                },

                    language: {

                        "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"


               }
                });
        });


    </script>
Prashant Pimpale
  • 8,749
  • 6
  • 30
  • 70

1 Answers1

-1

Please refer the following question where they convert array object of JavaScript to CSV file, where you have to just add line break for first line text and next line text and then again line space between second to third line where you have array data.

[How to export JavaScript array info to csv (on client side)? answer]

const rows = [["name1", "city1", "some other info"], ["name2", "city2", "more info"]]; let csvContent = "data:text/csv;charset=utf-8,"; rows.forEach(function(rowArray){ let row = rowArray.join(","); csvContent += row + "\r\n"; });