制表器未使用Tabulator.download下载

时间:2018-12-04 23:13:01

标签: download tabulator

制表器无法使用Tabulator.download()下载。我尝试使用CSV以及xlsx格式,但是没有成功。我在react组件中使用npm包。数据在UI的表格中可见。

它在以下功能上失败:

Download.prototype.downloaders = {
    csv: function csv(columns, data, options, setFileContents, config) 

控制台中显示的堆栈跟踪为:

 Cannot read property 'forEach' of undefined
  at parseRows (tabulator.js:11677)
  at Download.csv (tabulator.js:11722)
  at Download.download (tabulator.js:11419)
  at Tabulator.download (tabulator.js:8337)

1 个答案:

答案 0 :(得分:0)

原来,这是制表器的反应版本特有的问题。在这里找到解决方案:

https://github.com/ngduc/react-tabulator/issues/76

只需将其添加到您的选项对象中即可:

options  = {
    downloadDataFormatter: (data) => data,
    downloadReady: (fileContents, blob) => blob,
}