+ Remove white space when export to excel

This commit is contained in:
Djery-Tom 2020-07-29 14:40:25 +01:00
parent 31ac8e45d5
commit 890ff5c0e5
3 changed files with 38 additions and 9 deletions

View File

@ -200,6 +200,19 @@
'pageLength',
{
extend: 'excelHtml5',
customizeData: function (data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// data.body[i][j] = '\u200C' + data.body[i][j];
if ([1, 2].includes(j)) {
// Get the value and strip the non numeric characters
// var value = $(this).text();
value = data.body[i][j].replace(',', ".")
data.body[i][j] = Number(value.replace(/[^0-9\.-]+/g, ""));
}
}
}
},
customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'],
sum = 0;

View File

@ -111,7 +111,7 @@
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('recharge_historic'); ?></h3>
<h3 class="box-title"><?php echo $this->lang->line('refund_history'); ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<?php

View File

@ -276,14 +276,29 @@ use Brick\Money\Money;
title: 'Histrotique des transactions',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
},
customizeData: function (data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// data.body[i][j] = '\u200C' + data.body[i][j];
if ([3, 4, 7, 8, 9, 10, 11, 12, 13].includes(j)) {
// Get the value and strip the non numeric characters
// var value = $(this).text();
value = data.body[i][j].replace(',', ".")
data.body[i][j] = Number(value.replace(/[^0-9\.-]+/g, ""));
}
}
}
},
trim: false
},
{
extend: 'csvHtml5',
title: 'Histrotique des transactions',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
}
},
trim: false
},
{
extend: 'pdfHtml5',
@ -292,7 +307,8 @@ use Brick\Money\Money;
title: 'Histrotique des transactions',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
}
},
trim: false
},
// 'colvis'
]