最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - Tabulator : importing XLSX returns "TypeError: t.replace is not a function" - Stack Overflow

programmeradmin1浏览0评论

I have a table with editable columns. I'd like to let the users import data to massively update the table at once. As tabulator can't use the import in update mode, I instantiate a 2nd tabulator and call import on that one (the idea being to do : importtab.getData() => some processing => realtab.updateData())

Anyway : if I call tabulatorImport.import('xlsx', '.xlsx', 'buffer'), I get to choose a file, and then the Tabulator displays "Loading" while this error appears in the console. Note that I'm using a file that was exported from the same tabulator (tabulatorImport.download('xlsx', 'foobar.xlsx')) without any modification to it yet.

> ERROR TypeError: t.replace is not a function
>     at Object.r [as decode] (node_modules\xlsx\dist\xlsx.full.min.js:10:27204)
>     at Fg (node_modules\xlsx\dist\xlsx.full.min.js:23:11690)
>     at Wg (node_modules\xlsx\dist\xlsx.full.min.js:23:13623)
>     at Object.Wg [as read] (node_modules\xlsx\dist\xlsx.full.min.js:23:13002)
>     at TabulatorFull.xlsx (tabulator_esm.mjs:13463:22)
>     at tabulator_esm.mjs:13623:21

If I call tabulatorImport.import('csv', '.csv'), it work well, and I can log a getData() to check it. With 1 minor and 1 major inconveniences : (1) I'll need to write import mutators to revert the work done by formatters and download accessors (2) the csv wants comma "," whereas my users will save them from excel and obtain semicolons ";" (not to mention all csv imports in the app are expecting semicolons). And tbh, I'd really prefer XLSX over CSV, as this functionality will have best UX if people can re-import the exported excel file.

I have a table with editable columns. I'd like to let the users import data to massively update the table at once. As tabulator can't use the import in update mode, I instantiate a 2nd tabulator and call import on that one (the idea being to do : importtab.getData() => some processing => realtab.updateData())

Anyway : if I call tabulatorImport.import('xlsx', '.xlsx', 'buffer'), I get to choose a file, and then the Tabulator displays "Loading" while this error appears in the console. Note that I'm using a file that was exported from the same tabulator (tabulatorImport.download('xlsx', 'foobar.xlsx')) without any modification to it yet.

> ERROR TypeError: t.replace is not a function
>     at Object.r [as decode] (node_modules\xlsx\dist\xlsx.full.min.js:10:27204)
>     at Fg (node_modules\xlsx\dist\xlsx.full.min.js:23:11690)
>     at Wg (node_modules\xlsx\dist\xlsx.full.min.js:23:13623)
>     at Object.Wg [as read] (node_modules\xlsx\dist\xlsx.full.min.js:23:13002)
>     at TabulatorFull.xlsx (tabulator_esm.mjs:13463:22)
>     at tabulator_esm.mjs:13623:21

If I call tabulatorImport.import('csv', '.csv'), it work well, and I can log a getData() to check it. With 1 minor and 1 major inconveniences : (1) I'll need to write import mutators to revert the work done by formatters and download accessors (2) the csv wants comma "," whereas my users will save them from excel and obtain semicolons ";" (not to mention all csv imports in the app are expecting semicolons). And tbh, I'd really prefer XLSX over CSV, as this functionality will have best UX if people can re-import the exported excel file.

Share Improve this question asked Jan 31 at 15:22 KeorlKeorl 3442 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

After updating Tabulator's npm package, you also need to update xlsx manually. Versions that work together :

    "tabulator-tables": "^6.3.1",
    "xlsx": "^0.18.5",
发布评论

评论列表(0)

  1. 暂无评论