SheetJS / sheetjs

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
https://sheetjs.com/
Apache License 2.0
35.14k stars 8k forks source link

sheet_to_csv number format issue #1868

Closed carbuz closed 4 years ago

carbuz commented 9 years ago

the utils.sheet_to_csv function converts cells using the text value (w) instead of the value(v) (so numbers are rounded ...)

SheetJSDev commented 9 years ago

This is consistent with Excel. If you have an example where saving as CSV from excel does not round and exporting to csv from js-xls does round, please share or email me the file.

I wouldn't be against making this an option (like the JSON raw option)

carbuz commented 9 years ago

Hi,

thank you for your extremely quick answer and for your work in updating your amazing library! You are right: it is consistent with Excel. However it would be nice to have the possibility to load the data without the rounding (consider for example the possibility to import data from an excel to a database, etc...).

Thanks again for your time, Have a nice day!

Andrea

2015-02-27 18:08 GMT+00:00 SheetJSDev notifications@github.com:

This is consistent with Excel. If you have an example where saving as CSV from excel does not round and exporting to csv from js-xls does round, please share or email me the file.

I wouldn't be against making this an option (like the JSON raw option)

— Reply to this email directly or view it on GitHub https://github.com/SheetJS/js-xls/issues/71#issuecomment-76442597.

Andrea Carbone VP Enterprise Solution

Fincluster LTD Registered Office: 12, Bridewell Place, EC4V 6AP, London (UK) Registered in England & Wales no. 08359023 Operating Office: 3rd Floor, 28, Leman Street, E1 8ER, London (UK) M UK: +44 7557446765 M IT: +39 338 5938367 E: a.carbone@fincluster.com Skype: andrea.carbone.fincluster

This e-mail contains confidential information or information belonging to the Fincluster LTD entity sending it and is intended solely for the addressees. Any views expressed in this message are those of the individual sender and its contents do not constitute a commitment by Fincluster LTD unless confirmed by letter or fax. The unauthorised disclosure, use, dissemination or copying (either whole or partial) of this e-mail, or any information it contains, is prohibited. E-mails are susceptible to alteration and their integrity cannot be guaranteed. Internet communications are not secured and therefore Fincluster LTD shall not be liable for this e-mail if modified or falsified. If you are not the intended recipient of this e-mail, please notify the sender of the wrong delivery and delete it immediately from your system.

SheetJSDev commented 9 years ago

To understand the problem with "raw csv", lets start from a simple question: how should dates be written? After all, CSV is ultimately a string. There are multiple "good" answers here:

1) Converting the date object to a string: Fri Feb 27 2015 14:11:00 GMT-0500 (EST)

2) The ISO8601 with milliseconds (JSON.stringify does this): 2015-02-27T19:12:08.000Z

3) Duration format (used in ODS)

4) Try to determine the system locale

If you just want an array-of-arrays, the sheet_to_json function can be called with the options {header:1, raw:true}

carbuz commented 9 years ago

Hi, thank you for your answer. I would suggest you to give the option to save numbers in raw and date using in ISO format. The only thing that really matter is not to lose precision in saving any kind of data.

Best regards

SheetJSDev commented 9 years ago

@carbuz migrating to js-xlsx

YAmikep commented 7 years ago

Is it now possible to get raw values for numbers in sheet_to_csv with the new js-xlsx? I could not find the answer in the documentation: https://github.com/SheetJS/js-xlsx Thanks