Giter Club home page Giter Club logo

Comments (9)

maxstudener avatar maxstudener commented on August 11, 2024

The reason xlsx file return an int is because the type of the field is text, if in excel you change it to text you then see the integer, im running mac Excel 2011

from rubyxl.

jdavo avatar jdavo commented on August 11, 2024

I believe this appears similar to #31

from rubyxl.

brazir avatar brazir commented on August 11, 2024

Ah yes the 4000 error I have seen this in our prod environment as well and they have been fixing it with formatting the field to a date

from rubyxl.

crm114 avatar crm114 commented on August 11, 2024

Ugly hack but it works.

require 'rubyXL'
workbook = RubyXL::Parser.parse "workbook.xlsx"
worksheet = workbook.worksheet.first.get_table[:ẗable]
date_integer = worksheet.first["Date"]
=> 40981 # Number of days since Date.new(1900)
formatted_date = Date.new(1900) + date_integer
=> Thu, 15 Mar 2012

from rubyxl.

brazir avatar brazir commented on August 11, 2024

I have an example locally now seems to be when the the number format is not correctly determined to be a date excel stores dates as number hence the 4000 number if the format is not properly detected you can see the fixnum representation instead of the date hope to have a patch today

from rubyxl.

brazir avatar brazir commented on August 11, 2024

should be fixed in 1.2.10 so if it still broken comment on the ticket closing for now

from rubyxl.

ssickles avatar ssickles commented on August 11, 2024

I am using version 1.2.10 and I am still seeing the problem as described above.

The cell in my spreadsheet has a cell format of "Date". What might be more interesting to the developer is the more detailed configuration. When setting the cell format to "Date" you can also pick what "Type". When select a type beginning with a *, RubyXL doesn't recognize this as a date. If I choose a different one, such as "3/14/01" RubyXL does correctly identify it as a date. If you read further at the bottom of the screen when setting a "Date" format it reads.

"Date formats display date and time serial numbers as date values. Date formats that begin with an asterisk (*) respond to changes in regional date and time settings that are specified for the operating system. Formats without an asterisk are not affected by operating system settings."

I would guess that in order to achieve this, excel is storing the value as an integer. Perhaps RubyXL isn't able to detect this slight difference.

from rubyxl.

homezada avatar homezada commented on August 11, 2024

formatted_date = Date.new(1900) + date_integer

..is out by two days. See here for a workaround:

http://www.databasically.com/2011/04/22/rubys-parseexcel-and-the-extra-date/

..so it should be:

Date.civil(1899, 12, 31) + date_integer - 1.day

from rubyxl.

weshatheleopard avatar weshatheleopard commented on August 11, 2024

@homezada: not sure what you are talking about. Can you provide a test case? Dates work as expected for me.

from rubyxl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.