Wednesday
Hi everyone,
I'm currently working with the export functionality of a Smart Table, where I need to download the table data as a spreadsheet. There's a specific column called "Due Date" that receives data from the backend in the yyyymmdd format (e.g., 20240630) which I am getting in string type. For displaying this in the table, I use a formatter to convert it to dd/mm/yyyy format (e.g., 30/06/2024).
However, when exporting the data, the spreadsheet still contains the date in the yyyymmdd format. I would like to format the data to dd/mm/yyyy before exporting it to the spreadsheet.
Can anyone provide guidance on how to achieve this?
Thanks in advance!
SAPUI5
Thank you @junwu
I have implemented your suggested solution with additional enhancements. We utilize the `beforeExport` event of the smart table to call a function that sets the properties and formatting of the values. Here is the implemented solution.
onBeforeExport: function(oEvent) {
var oExportSettings = oEvent.getParameter("exportSettings");
var aColumns = oExportSettings.workbook.columns;
var iDueDateColumnIndex = aColumns.findIndex(function (oColumn) {
return oColumn.property === "DueDate";
});
if (iDueDateColumnIndex !== -1) {
aColumns[iDueDateColumnIndex] = {
label: 'Due Date',
type: 'string',
property: 'DueDate',
inputFormat: "([0-9]{4})([0-9]{2})([0-9]{2})",
template: "{2}/{1}/{0}",
width: 10
};
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use this when you build the spreadsheet
{
label: 'DateString',
type: EdmType.Date,
property: 'SampleDateString',
inputFormat: 'yyyymmdd',
format:'dd/mm/yyyy'
width: 25
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
11 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.