-
Notifications
You must be signed in to change notification settings - Fork 20
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
Get raw value of the cell #59
Comments
There is currently no way of doing this. By design Xsv returns arrays of parsed primitives instead of proxy objects. The parsing for a 'd' type cell happens in xsv/lib/xsv/sheet_rows_handler.rb Lines 109 to 110 in e5d18c6
Perhaps you can reverse the effect of |
I cannot reverse it because I am getting the Date object, not DateTime. Even though the underlying raw value has a time component saved, I am not getting datetime back because the cell is formatted as Date in xlsx. If I open xlsx file and change cell format to DateTime, then I get datetime value from xsv too. However those files are exported from a different system that I don't have control of so I need a way to either to override cell style/format or get access to raw value and convert it to datetime myself. |
Ah, I forgot that exists. Indeed what you have is a number formatted as a date. The conversion is done by adding the number value to an epoch.
This can be reversed:
I hope that helps! It would be interesting idea to add a middleware pipeline to Xsv to customize the parsing, but I have no time to build that. PR's are always welcome, though! |
I have xlsx file that has a date column. The underlying value is a float (has a time component). I want to get the raw value of the cell to convert it to datetime even though the cell is formatted as Date.
I looked through code and could not find a good was to access the cell's raw value. Is there way to return cell's raw value or override the formatting?
The text was updated successfully, but these errors were encountered: