0
votes

I am trying to export my SAP UI5 table data to csv file using following function,

           table_export = oTable.exportData();
            table_export.saveFile('MY');

also tried,

   oTable.exportData().saveFile('MY');

But I am getting the following error

      Uncaught TypeError: Cannot read property 'indexof' of undefined

Someone could help me with the error

BR- Sathish

1
I guess your error comes from something else, it should work just fine... have you imported the Export and ExportTypeCSV classes in your page? - Qualiture
Also, have you specified the exportType in the exportData() call? See openui5.hana.ondemand.com/#docs/guide/… for an example. - qmacro
Hi Guys, thanks for the reply. Yes i saw the above link and already have the classes included. and i have defined my export type as ExportTypeCSV()... but again i am getting the same error. I found one more link openui5beta.hana.ondemand.com/docs/guide/relnotes/… .. may be its due to version.. but not sure.. . - Sathish Selvaraj
I have managed to export the files using some available codes using data URI schema functionality, it works fine but in IE 8.. :(.. You guys have any idea .. i am opening another post for this.. - Sathish Selvaraj
Pretty sure you are calling "indexof" instead of "indexOf" somewhere in your code. JavaScript is case sensitive. - Chris Neve

1 Answers

0
votes

On click off button you can download your table in excel format

new sap.m.Button({
    icon:"sap-icon://download",
    type:"Emphasized",
    press: function(oEvent) {
        debugger;

        jQuery.sap.require("sap.ui.core.util.Export");
        jQuery.sap.require("sap.ui.core.util.ExportTypeCSV");

        oTable.exportData({

        }).saveFile()
        .always(function() {
            this.destroy();
        });

while defining your table columns, mention the below properties too.

sortProperty: "approved_on",
filterProperty: "approved_on"

Note: "approved_on" is the value binded to the respective column.