cancel
Showing results for 
Search instead for 
Did you mean: 

SmartTable Excel Download Date format issue

bhavya_sri3
Participant
2,642

I'm using sap.ui.comp.smarttable.SmartTable for displaying data in table. I was able to display Dates in Date format by using CustomData.

But when I'm downloading data in Excel, it is showing data in json date format

/Date(1451606400000)/

I was able to show date format by using the onBeforeExport event, by passing type as Edm.Date type. This way, I was able to display json date as Date in MM/dd/yyyy format. But my requirement is to show date as dd/MM/yyyy. I understand that I need to use inputFormat property, but I could not figureout how to pass the property as my required data. Can anyone please suggest on the format I need to use..

maheshpalavalli
Active Contributor
0 Kudos

Hi Bhavya,

Is the column property type that is coming from backend is of type date or string?

BR

Mahesh

Accepted Solutions (0)

Answers (4)

Answers (4)

HI,

I have also faced the same issue.

I have and extended column with date, but after giving type property as date, it was working.

<core:CustomData key="p13nData" value='\{"columnKey": "Callback", "sortProperty": "Callback","filterProperty":"Callback","columnIndex":"7", "leadingProperty": "Callback", "type":"date"}'/>

Thanks Manish!

maheshpalavalli
Active Contributor

Hi Bhavya,

In the custom data that you are using, try passing the type as well:

...."leadingProperty":"", "type":"date" }'/>

in the custom data along with the other properties you are passing,

BR,
Mahesh

bhavya_sri3
Participant
0 Kudos

Hi Mahesh,

I tried using the date type in custom data.. but it has no affect on the excel.. still getting the date in MM/dd/yyyy format.

Thanks,

Bhavya

maheshpalavalli
Active Contributor
0 Kudos

Hi Bhavya, What is the type of that property you are receiving from the backend, it is string or date?

BR,Mahesh

maheshpalavalli
Active Contributor
0 Kudos

You can see the example here as well, which showcases two scenarios

1. If the date is coming as a string

2. If the date is coming as a date type

https://ui5.sap.com/#/sample/sap.ui.export.sample.formatting/code/Spreadsheet.controller.js

I am still wondering why you are using the custom column? to do any formatting?(I dont see any formating there).

BR,
Mahesh

bhavya_sri3
Participant
0 Kudos

Hi Mahesh,

Sorry for the delayed response..

I'm receiving date in the 'date' type from backend. It is coming in json format something like /Date(1490918400000)/

I have tried changing the settings similar to that of in the example but it is still not showing in correct format..

aCols.push({

label: 'DateString',

type: 'date',

property: 'SampleDateString',

inputFormat: 'yyyymmdd',

width: 25 });

Thanks,

Bhavyasri M

AdrDen
Explorer
0 Kudos

Hi,

Did someone find a solution for this? I've also tried onBeforeExport event, but without any success.

BR,

Adrian

junwu
Active Contributor
0 Kudos

change inputFormat to format to see if it helps

bhavya_sri3
Participant
0 Kudos

The SmartTable is using Spreadsheet api internally and it seems it doesn't have "format" property for workbook.columns..

https://sapui5.hana.ondemand.com/#/api/sap.ui.export.Spreadsheet/constructor

Thanks,

Bhavyasri M

junwu
Active Contributor
0 Kudos

can you just try? it is no harm.....

bhavya_sri3
Participant
0 Kudos

I tried.. it is not throwing any error but it is still showing the date in MM/dd/yyyy format..

Tried these two statements..

mExcelSettings.workbook.columns[33].format= "dd/MM/yyyy";

mExcelSettings.workbook.columns[33].format= "dd-MM-yyyy";

Do you think the date formats I'm trying to use are wrong?

Thanks,

Bhavya