Question T8336
Visible to All Users

Unable to export into excel with SurveyJs tabulator

created 3 years ago

Hello!

I tried to integrate survey analytics tabulator functionality to try out its excel export feature, however it is not working. Once I click on the Excel button, the following error is occurring in console:

errors.ts:30 ERROR ReferenceError: XLSX is not defined
at Tabulator.xlsx (tabulator.es2015.js:11928)
at Download…/node_modules/tabulator-tables/dist/js/tabulator.es2015.js.Download.download (tabulator.es2015.js:11636)
at Tabulator…/node_modules/tabulator-tables/dist/js/tabulator.es2015.js.Tabulator.download (tabulator.es2015.js:8884)
at Tabulator…/src/tables/tabulator.ts.Tabulator.download (tabulator.ts:397)
at HTMLButtonElement.onclick [as __zone_symbol__ON_PROPERTYclick] (tabulator.ts:157)
at HTMLButtonElement.wrapFn (zone.js?v=2IeQSCTDsAy5mjNmNhsdJZSpJxOKEV1VNZLMjf6LfFc:798)
at ZoneDelegate.invokeTask (zone.js?v=2IeQSCTDsAy5mjNmNhsdJZSpJxOKEV1VNZLMjf6LfFc:429)
at Object.onInvokeTask (ng_zone.ts:293)
at ZoneDelegate.invokeTask (zone.js?v=2IeQSCTDsAy5mjNmNhsdJZSpJxOKEV1VNZLMjf6LfFc:428)
at Zone.runTask (zone.js?v=2IeQSCTDsAy5mjNmNhsdJZSpJxOKEV1VNZLMjf6LfFc:200)

The project is in angular, I was using this tutorial:
https://surveyjs.io/Examples/Analytics?id=nps-tabulator&platform=Angular&theme=modern#content-result

Survey js Analytics version - 1.9.

My code sample:

Code
import { Tabulator } from 'survey-analytics/survey.analytics.tabulator';
Code
var survey = new Survey.Model(this.analytics.body);   var surveyResultNode = document.getElementById('surveyResult');   surveyResultNode.innerHTML = '';   var options = {     haveCommercialLicense: true   };   var surveyAnalyticsTabulator = new Tabulator(survey, this.analytics.answers, options);   surveyAnalyticsTabulator.render(surveyResultNode);

Are there any additional set-ups needed?

Will appreciate any help with the issue.

Thanks!

Answers approved by surveyjs Support

created 3 years ago

Hello,

Excel export is a 3rd party plugin of tabulator library we're using to show table representation.
According it documentation http://tabulator.info/docs/4.1/download#xlsx you need to load sheetjs library to your web page via the

HTML
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>

Here is the CodeSandbox live sample - https://codesandbox.io/s/surveyjs-angular-forked-il1mn?file=/src/index.html
If you open it in a separate window, it will produce xls file export

Thanks, Serge
SurveyJS Team