Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to modified number value #2597

Open
RPethani opened this issue Oct 26, 2020 · 5 comments
Open

Access to modified number value #2597

RPethani opened this issue Oct 26, 2020 · 5 comments

Comments

@RPethani
Copy link

Is there any way to access modified version of value as number ?

For example,

Input = 1.2345678
Format = "$ 0.00"
Formatted string = "$ 1.23"
Can we get formatted value as number = 1.23

Is there any such possibility ?

@snoopyjc
Copy link
Contributor

Can't you just parse it back out with a regex and then convert it to a float value?

@RPethani
Copy link
Author

RPethani commented Oct 28, 2020

Can't you just parse it back out with a regex and then convert it to a float value?

The problem is that format is configurable by users and we would not know what they have configured. So we can't have fix regex to parse value back. That is why i was wondering if modified raw value was queryable.

@SheetJSDev
Copy link
Contributor

Support for locale-aware value parsing is definitely a goal, but currently we don't have support for that. CSV parsing requires this type of value logic, and there's a very rough sketch in our file processing library https://github.com/SheetJS/sheetjs/blob/master/bits/40_harb.js#L835-L859

@snoopyjc
Copy link
Contributor

@RPethani If you only need number (not date) results, try grabbing the value of ostr from https://github.com/SheetJS/ssf/blob/master/ssf.js#L824 - this is the number string before it's put back into the user's format.

@RPethani
Copy link
Author

@RPethani If you only need number (not date) results, try grabbing the value of ostr from https://github.com/SheetJS/ssf/blob/master/ssf.js#L824 - this is the number string before it's put back into the user's format.

@snoopyjc This sounds interesting. I will try it out. Thank you so much for the help.

@reviewher reviewher transferred this issue from SheetJS/ssf Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants