Question T14094
Visible to All Users

CSV and Excel callback on download

created a year ago

Hi!

Can I made a hook/callback to catch URL of generated download CSV/Excel, or to change data before start download?
In tabulator I found https://tabulator.info/docs/5.5/callbacks#download

Code
downloadDataFormatter

and

Code
downloadReady

But it seems that I can't use this in survey tabulator?

Answers approved by surveyjs Support

created a year ago

Hello Gordey,
According to the Tabulator documentation (Download Callbacks), you can use the downloadReady callback to intercept the download file data before a file is downloaded.

In SurveyJS Dashboard, you can access this callback using the tabulatorTables object instance. Note that this object is available after a render function of a dashboard is called.

JavaScript
var visPanel = new SurveyAnalyticsTabulator.Tabulator( survey, dataFromServer ); visPanel.render("surveyDashboardContainer"); visPanel.tabulatorTables.options.downloadReady = function(fileContents, blob){ //fileContents - the unencoded contents of the file //blob - the blob object for the download //custom action to send blob to server could be included here return blob; } });

Example.

For the record: if you need to perform changes to the table data before it is parsed into the download file, use the onDownloadCallback function.

I hope this information helps. Please let me know if you have any question or require further assistance.