1
votes

I am using a SAP UI5 application and trying to export table data into a word document but get an undefined error in document. I am using jquery.wordexport.js as in example here. My html code is as defined below

<head>
    <script src="FileSaver.js"></script> 
    <script src="jquery.wordexport.js"></script> 
    <script>
        sap.ui.localResources("odataservice");
        var app = new sap.m.App({
            initialPage:"idodataservice1"
        });
        var page = sap.ui.view({
            id: "idodataservice1", 
            viewName: "odataservice.odataservice", 
            type: sap.ui.core.mvc.ViewType.XML
        });
        app.addPage(page);
        app.placeAt("content");
    </script>
</head>
<body class="sapUiBody" role="application">
    <div id="content">Hi</div>
</body>

The div content is having a table shown on screen and is not empty, on click of button I am calling below method

onPressExport: function() {
    jQuery(document).ready(function($) {
        $("content").wordExport();
    });
},

I have added both files at the root level and export document does come in but with text 'undefined' written inside it. Tried checking the id at runtime in console and tried different sub div Ids as well but still get undefined error. Please suggest what could be wrong here or am I missing something.

1
If you see the comments on that plugin, there are lots of users who have issues with it. IMO, you shall not use client-side scripts to export to Word, Excel, etc, but use a proper server to do the task for you - Qualiture

1 Answers

0
votes

You don't need the 'ready' event inside the OnPressExport:

onPressExport: function() {
    $("content").wordExport();
},