Skip to content

Commit 4c68073

Browse files
committed
fix: ioet#429 set duration column as duration format in xls
1 parent 185143f commit 4c68073

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {EntryState} from '../../../time-clock/store/entry.reducer';
55
import {entriesForReport} from '../../../time-clock/store/entry.selectors';
66
import {Subject} from 'rxjs';
77
import {DataTableDirective} from 'angular-datatables';
8+
import * as moment from 'moment';
89

910
@Component({
1011
selector: 'app-time-entries-table',
@@ -13,6 +14,7 @@ import {DataTableDirective} from 'angular-datatables';
1314
})
1415
export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewInit {
1516
data = [];
17+
1618
dtOptions: any = {
1719
scrollY: '600px',
1820
paging: false,
@@ -22,11 +24,27 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
2224
'print',
2325
{
2426
extend: 'excel',
27+
exportOptions: {
28+
format: {
29+
body: ( data, row, column, node ) => {
30+
return column === 2 ?
31+
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
32+
data;
33+
}
34+
}},
2535
text: 'Excel',
2636
filename: `time-entries-${ formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en') }`
2737
},
2838
{
2939
extend: 'csv',
40+
exportOptions: {
41+
format: {
42+
body: ( data, row, column, node ) => {
43+
return column === 2 ?
44+
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
45+
data;
46+
}
47+
}},
3048
text: 'CSV',
3149
filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en') }`
3250
}

0 commit comments

Comments
 (0)