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
Explicit "text" columns being imported at :float anyway #53
Comments
I have run into this issue as well. I tried to find implied cell formats that are part of the OOXML format, but apparently I am too dumb to locate them in the massive pile of specification documents (http://www.ecma-international.org/publications/standards/Ecma-376.htm). So what i am about to say is part conjecture and part google:
It appears that when you set a cell to a format of "Text" the underlying number format has a numFmtId of 49 ... which corresponds to '@'. This represents a simple text placeholder. If this is correct, Format.to_type() should return :string is the format equals '@'. I am not sure if you want to get into the whole rats nest that is possible when using @ in a more complex text placeholder format, such as 'My name is @'. If this is correct, I would be more than happy to submit a patch to the tests and the lib code for this. C |
Does this issue still exist in the current version of Roo? I now it's been a while, but can you create a gist that illustrates this issue?
|
From @carlost 's comment, it is pretty safe to make an assumption interpreting format '@' is string (text) type. It solves many long standing issues . return :string if format == '@' Modify file def to_type(format)
format = format.to_s.downcase
if (type = EXCEPTIONAL_FORMATS[format])
type
elsif format.include?('#')
:float
elsif !format.match(/d+(?![\]])/).nil? || format.include?('y')
if format.include?('h') || format.include?('s')
:datetime
else
:date
end
elsif format.include?('h') || format.include?('s')
:time
elsif format.include?('%')
:percentage
elsif format == '@'
:string
else
:float
end
end |
@stevendaniels |
I've submitted a request (#240) that proper type support to Excel. It's a big request, so it will probably take some time before it gets pulled into master. |
#240 resolves this issue. Add the following to your gemfile to install it.
I will work on publishing a new version of the gem to Rubygems this weekend. |
@stevendaniels |
Any updates on this? It's adding a '.0' on all my columns like id or zip code 😬 |
Facing the same issue. Any work around? |
Trying to convert that column to column.to_i. |
you can't convert column.to_i as it will get rid of the leading 0s. |
Hey guys-
So, I have a spreadsheet a column of unformatted phone numbers (we have international users, so a one-size-fits-all format is impractical) — most of these are simply numbers, but even when the xlsx (or xls) column type is set to "Text", these still come in as Floats and end up imported with a ".0" at the end.
This is obviously incorrect, but I really thought the column type would be respected.
Am I doing anything obviously wrong here, or is there an issue?
The text was updated successfully, but these errors were encountered: