When I try to export data to excel in angular, the date in database is in 'x' timezone and I'm exporting data from 'y' timezone. While data is getting exported to excel, date is in 'y' timezone. But i want to keep it same as date in database i.e, date with 'x' timezone only.
I expect output as Mar 26 2014 12:00 AM
but I'm receiving this 2014-03-25 23:00:00.000+0000
.
private export(records: any[]) {
// get the export fields
let exportFields = this.gridConfig.columnDefinitions.map(function (colDef) {
if(false == colDef.exportField) {
return;
}
return colDef.field;
});
let filtered = this.gridOptions.api.getSelectedRows().map(record => {
return _.pick(this.flatten(record), exportFields);
});
const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(filtered);
let range = XLSX.utils.decode_range(ws['!ref']);
for(let c = range.s.c; c <= range.e.c; ++c) {
let address = XLSX.utils.encode_col(c) + "1"; // <-- first row, column number C
if(!ws[address]) continue;
ws[address].v = this.findHeaderNameByField(ws[address].v);
}
/* generate workbook and add the worksheet */
const wb: XLSX.WorkBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'data');
/* save to file */
XLSX.writeFile(wb, 'Export.xlsx');
}
When I debugged I found that data from api is only receiving as time with 'y' zone.