SheetJS / js-codepage

:currency_exchange: Codepages for JS
http://sheetjs.com
Apache License 2.0
151 stars 39 forks source link

NodeJs v.6.0.0 introduces issue with cpexcel.js Buffer usage. #12

Closed macyabbey closed 7 years ago

macyabbey commented 8 years ago

Setting the length property after construction of Buffer objects is no longer valid.

Reading an excel spreadsheet buffer yields:

TypeError: Cannot set property length of [object Object] which has only a getter at sbcs_d (.../node/node_modules/xlsx/dist/cpexcel.js:909:20) at Object.decode (.../node_modules/xlsx/dist/cpexcel.js:1197:40) at _gc2 (.../node/node_modules/xlsx/xlsx.js:28:24) at Buffer.ReadShift as read_shift at parse_XLUnicodeStringNoCch (.../node/node_modules/xlsx/xlsx.js:3113:23) at parse_XLUnicodeString (.../node/node_modules/xlsx/xlsx.js:3121:9) at parse_XLUnicodeString2 (.../node/node_modules/xlsx/xlsx.js:3125:48) at Object.parse_Format as f at slurp (.../node/node_modules/xlsx/xlsx.js:9229:11) at parse_workbook (.../node/node_modules/xlsx/xlsx.js:9350:15) +0ms .../node/node_modules/xlsx/xlsx.js:9350:15)

Just removing the statement at line 909 seems to make everything work again, but not sure how safe this is without fully understanding the context. Hoping someone with more knowledge of this library can provide the right fix.

reviewher commented 7 years ago

The relevant fixes have been committed here and pushed to both js-xlsx and js-xls.