cancel
Showing results for 
Search instead for 
Did you mean: 

download sap.m.table to excel format

Former Member
0 Kudos

Hello

I want to download my table into excel format.

I used the below code but it is taking all the fields from collection.

Download: function(){

   var sServiceUrl = "/sap/opu/odata/sap/ZDEMO_GW_SRV_SRV/SalesOrderSet?$format=xlsx";

          var encodeUrl = encodeURI(sServiceUrl );

   sap.m.URLHelper.redirect(encodeUrl,true);

  },

But my requirement is, suppose i have few fields/ columns from collection(entity set) and i applied filter as well.. And now i want to download what I am viewing on my screen.

Question in nutshell

How can i download only selected columns and  filtered data from table to excel.??

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Kiran ,

There are two ways :

1. using  SAPUI5 export class(sap.ui.util.Export) - refer this example ,as the download is using through the service not the visible table , you need to mention only those fields which you want in excel ..

example : SAPUI5 Explored

2. using HTML table tag download -  refer the answer in this link , this will download what you view on the screen .

link : Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browse -...

Note : its better to download using the service (entitySet) because this will give you actual content ,, while downloading what you see on screen will not be good option because some data which is not render on the page will be missing in the excel ..

Check your requirement use accordingly ...

thanks

Viplove

Former Member
0 Kudos

Hi Viplove

In first case, when i download it is not in proper view in excel. see it is downloading as shown in below snapshot.

Is there something silly concept that i am missing?

mantrishekar
Active Participant
0 Kudos

Hi Kiran,

Could you please paste the properties defined for the

new sap.ui.core.util.Export

Regards,

Shekar

Former Member
0 Kudos

Hi Kiran ...

Go with this ... Exporting to Excel from sap.m.Table via csv | SCN  ... actually in that the download is like that only ... i was also not able to do in proper format ... just now i see my code what i did in my project .. its very much similar to the above mentioned link code..

note : be sure the code links i am sharing are in csv format ... not excel

thanks

Viplove

former_member227918
Active Contributor

Hi Kiran,

Change separatorChar as below :

instead of :

exportType : new sap.ui.core.util.ExportTypeCSV({

                separatorChar : ";",

                charset : "utf-8",

            }),

use this :

exportType : new sap.ui.core.util.ExportTypeCSV({

                separatorChar : ",",

                charset : "utf-8",

            }),

Regards,

Akhilesh