jecovier / vue-json-excel

MIT License
687 stars 168 forks source link

Issue printing numbers starting with 0s #107

Open soulfreaky opened 5 years ago

soulfreaky commented 5 years ago

Hi! I'm having an issue when I'm trying to pass a value starting with 0 to the excel, for example if I pass the value '0000234', when I download the excel it appears as '234'. I'm guessing that the Excel is treating the value as a number instead of a string, and I tried using a callback with the .toString() method with no luck.

Any help with this? would be deeply appreciated.

Thanks!

innozent commented 5 years ago

Hi

I just face the same issue and can get it resolved by workaround to put zero-width whitespace in front of value using callback.

you can copy zero white space character from below link https://beautifuldingbats.com/punctuation/whitespace/

then put it in your field call back

"telephone": {field: "user.telephone", callback: value =>  ​${value}}

with the extra white space in between and $ of${value}

but the down side if user use VLOOKUP function in excel it will consider the white space as well.

soulfreaky commented 5 years ago

Thanks for the solution! what I finally did is passing the value as ="value".

this shows the value correctly in the spreadsheet, but then if you look for it in the "formula" field you will see it with the =""

Ill try this one anyway!

El vie., 5 jul. 2019 5:59, innozent notifications@github.com escribió:

Hi

I just face the same issue and can get it resolved by workaround to put zero-width whitespace in front of value using callback.

you can copy zero white space character from below link https://beautifuldingbats.com/punctuation/whitespace/

then put it in your field call back

"telephone": {field: "user.telephone", callback: value => ​${value}}

with the extra white space in between and $ of${value}

but the down side if user use VLOOKUP function in excel it will consider the white space as well.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jecovier/vue-json-excel/issues/107?email_source=notifications&email_token=AENRYP2TFGXQ3EYS34CBPX3P53BIVA5CNFSM4H4P3HOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZIPFPY#issuecomment-508621503, or mute the thread https://github.com/notifications/unsubscribe-auth/AENRYP7BORVY4Y2YRXAJCBLP53BIVANCNFSM4H4P3HOA .

wangfei0 commented 1 year ago

我遇到了同样的问题,我的值为 "01234"字符串,导出后变成了 “1234” 。