Footer Data Effecting Excel Export...
Footer Data Effecting Excel Export...
MFG
Posts: 12Questions: 5Answers: 0
Is there any documentation, best practices or examples available on how to implement footers while maintaining the Column Auto Fit default associated with the ExcelHTML5 Export?
Most of our tables contain financial/numeric data and require footer information with totals and averages.
I am finding that the footer data is disrupting the Auto Fit sizing of columns when the table is exported to Excel.
Thank You.
Michael.
This discussion has been closed.
Answers
Apologies for not including an example. It can now be found here: http://live.datatables.net/ligiroyu/1/edit
Table 1 places the Page Totals & Grand Totals within a single
<tr>
inside<tfoot>
. The table looks fine during display. When the table is exported to Excel, the contents of the footer cells are not being wrapped - mashing the content together & making the cell width larger. I did not realize this until I addedfooter: true
to ExcelHtml5. I suspect the <br /> tags are the culprit, but don't know how to replace during Excel export.Table 2 is my attempt at adding a 2nd
<tr>
to<tfoot>
. However, I am not sure how to modify thefooterCallback
function in order to place each of the totals on their proper row. In addition the 2nd row is not being exported and it is not following the responsive behavior of the footer's first row. Resize the output window to see this.Hope all this makes sense now.
Any suggestions or guidance would be greatly appreciated.
Thank You.
Hi @MFG,
you can modify the below code according to your requirement.
`$(document).ready(function() {
var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
var d = day + "-" + month + "-" + year;
function getBase64FromImageUrl(url) {
var img = new Image();
img.crossOrigin = "anonymous";
img.onload = function () {
var canvas = document.createElement("canvas");
canvas.width =this.width;
canvas.height =this.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(this, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
};
img.src = url;
}
var table=$('#statistics').dataTable( {
"fnDrawCallback": function( oSettings ){
console.log("in");
},
dom: 'lBfrtip',
// "dom": '<"dt-buttons"Bf><"clear">lirtp',
"lengthMenu": [[4, 8, 12, -1], [4, 8, 12, "All"]],
autoWidth:true,
paging: true,
"pagingType": "full_numbers",
} );
} );
`
Thanks
Koka