5 Replies Latest reply on Jul 17, 2019 9:13 PM by Umer Khalid

    JS API select worksheet on tabswitch for data export

    Ted Slinkard

      trying to add a button so the users can export data using javascript API.


      currently have the button calling


      function ExportData() {




      the issue is we have multiple dashboards and when the users select a different tab(dashboard) the first worksheet is not automatically selected so it won't export anything.


      I'm trying to add an event listener, ignoring a few worksheets we have for layout of menu (thus the ignoreArray)  but I get the error Cannot read property activatesheetasync of undefined.  is there a better way of doing this?  just need to allow the users to export the data to csv so they can use in excel.


      viz.addEventListener('tabswitch', function () {

              var sheets = workbook.getActiveSheet().getWorksheets();

              var IgnoreArray = ["MenuIcon", "BlankSheet", "CloseIcon"];



              for (var i in sheets) {

                  if ($.inArray(sheets[i].getName(), IgnoreArray) < 0) {