I'm exporting to excel
my datatable
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:
Currently this is the result that I get, but I need to add text in the next row:
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>
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"; });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.