stephen-hardy / xlsx.js

XLSX.js is a JavaScript library for converting the data in base64 XLSX files into JavaScript objects - and back! Please note that this library is licensed under the Microsoft Office Extensible File License - a license NOT approved by the OSI. While this license is based off of the MS-PL, which is OSI-approved, there are significant differences.
http://blog.innovatejs.com/?tag=xlsx-js
Other
575 stars 122 forks source link

Force value to be parsed as text? #38

Open LeachBogdan opened 9 years ago

LeachBogdan commented 9 years ago

We have a very permissive phone no. field and would like all phone numbers to be parsed as text. Is there any way to do it?

LeachBogdan commented 9 years ago

I've managed to do it by adding a property (in my case forceString) to the cell when creating it and changing the string verification to also include it

if(val && typeof val === 'string' && !isFinite(val))

becomes

if( al && typeof val === 'string' && (!isFinite(val) || cell.forceString') 

at line 181.