Comments (9)
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.
I believe this appears similar to #31
from rubyxl.
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.
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.
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.
should be fixed in 1.2.10 so if it still broken comment on the ticket closing for now
from rubyxl.
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.
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.
@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)
- How to change the default data type of a column?
- RubyZip 3.0 will introduce breaking changes that rubyXL will currently depend upon HOT 1
- Got a string with a part missing when i read value from cell. HOT 1
- Cannot open xlsx file using rubyXL HOT 3
- cell and styles.xml HOT 1
- can't change border diagonal
- "Nokogiri::XML::SyntaxError (1:1: FATAL: Document is empty)" on parsing the buffer more than once HOT 1
- GitHub sponsor/open collective HOT 2
- `insert_column` with existing styled cell doesn't set cell `@worksheet`, causing failure in `LegacyCell#validate_worksheet` HOT 1
- How can I make a cell in the sheet dropdown list with accept multiple values? (multiple selection)? HOT 1
- Storage class not found for docProps/app.xml and xl/workbook.xml leading to error opening file
- AWS setup for E-mail processing HOT 1
- MissingFile error during send_file in rails
- Re-open #332
- undefined method `change_row_italics' HOT 1
- Obscure error raised when calling `parse_buffer` with an empty buffer HOT 1
- when i parse a xlsx file, change_contents not found. and how can i change merged cell content? HOT 1
- External link can not write to new file
- `#parse_buffer` unexpectedly modifies input buffer HOT 3
- Error Parsing Xlsx when it has links to other files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubyxl.