Access to modified number value #2597

Open
opened 2020-10-26 13:16:27 +00:00 by RPethani · 5 comments
RPethani commented 2020-10-26 13:16:27 +00:00 (Migrated from github.com)

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 ?

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 commented 2020-10-27 21:24:08 +00:00 (Migrated from github.com)

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

Can't you just parse it back out with a regex and then convert it to a float value?
RPethani commented 2020-10-28 07:07:01 +00:00 (Migrated from github.com)

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.

> 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 commented 2020-10-28 07:41:13 +00:00 (Migrated from github.com)

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

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 commented 2020-10-28 22:31:15 +00:00 (Migrated from github.com)

@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 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 commented 2020-10-29 06:43:35 +00:00 (Migrated from github.com)

@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.

> @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.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2597
No description provided.