date format support in roo

251 views
Skip to first unread message

PAV

unread,
Apr 30, 2011, 10:23:40 AM4/30/11
to ruby-roo
Hi,

I am testing roo and I have a problem reading xlsx files that contain
date formats like '12-apr-11'. When I change this to '12-04-11' it
works fine. But for the format I need, roo always returns a float
instead of a date.
The problem is that I cannot change these files manually to a format
that roo recognizes.
Is there a way to adapt the date formats roo recognizes?

Many thanks for your help!

Pascal

PAV

unread,
May 1, 2011, 9:01:02 AM5/1/11
to ruby-roo
Hi,

I found a way to fix this problem. The float value that roo returns
seems to correspond with the internal float value that Excel is using
for dates. The float value is the number of days since 1 January 1900.
But for some reason you need to subtract 2 days to get it correct. See
also http://www.ozgrid.com/Excel/ExcelDateandTimes.htm (there you can
read that MS counts 29 Feb 1900, but that date does not exist, what
partly explains the subtraction).

Hope this is helpful for others having problems with dates.

Regards,
Pascal

Thomas Preymesser

unread,
May 2, 2011, 12:57:11 PM5/2/11
to ruby...@googlegroups.com

Hi Pascal,

On 1 May 2011 15:01, PAV <pascal.v...@gmail.com> wrote:
Hi,

I found a way to fix this problem. The float value that roo returns
seems to correspond with the internal float value that Excel is using
for dates. The float value is the number of days since 1 January 1900.
But for some reason you need to subtract 2 days to get it correct. See
also http://www.ozgrid.com/Excel/ExcelDateandTimes.htm (there you can
read that MS counts 29 Feb 1900, but that date does not exist, what
partly explains the subtraction).


can you send me a spreadsheet file which causes this error? If it is a date field roo should also return a Date object.

-Thomas
 
Hope this is helpful for others having problems with dates.

Regards,
Pascal

On 30 apr, 16:23, PAV <pascal.verlin...@gmail.com> wrote:
> Hi,
>
> I am testing roo and I have a problem reading xlsx files that contain
> date formats like '12-apr-11'. When I change this to '12-04-11' it
> works fine. But for the format I need, roo always returns a float
> instead of a date.
> The problem is that I cannot change these files manually to a format
> that roo recognizes.
> Is there a way to adapt the date formats roo recognizes?
>
> Many thanks for your help!
>
> Pascal

--
You received this message because you are subscribed to the Google Groups "ruby-roo" group.
To post to this group, send email to ruby...@googlegroups.com.
To unsubscribe from this group, send email to ruby-roo+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ruby-roo?hl=en.




--
Thomas Preymesser
tho...@gmail.com
http://thopre.googlepages.com/
http://thopre.wordpress.com/

PAV

unread,
May 21, 2011, 10:34:38 AM5/21/11
to ruby-roo, Thomas Preymesser
Hi Thomas,

I've send you a mail with a sample file today.

Best Regards,
Pascal

On 2 mei, 18:57, Thomas Preymesser <tho...@gmail.com> wrote:
> Hi Pascal,
>
> On 1 May 2011 15:01, PAV <pascal.v...@gmail.com> wrote:
>
> > Hi,
>
> > I found a way to fix this problem. The float value that roo returns
> > seems to correspond with the internal float value that Excel is using
> > for dates. The float value is the number of days since 1 January 1900.
> > But for some reason you need to subtract 2 days to get it correct. See
> > alsohttp://www.ozgrid.com/Excel/ExcelDateandTimes.htm(there you can
> thopre@gmail.comhttp://thopre.googlepages.com/http://thopre.wordpress.com/

Thomas Preymesser

unread,
May 23, 2011, 2:38:27 PM5/23/11
to PAV, ruby-roo
Hello,

On 2011-05-21, PAV <pascal.v...@gmail.com> wrote:

>> > I found a way to fix this problem. The float value that roo returns
>> > seems to correspond with the internal float value that Excel is using
>> > for dates. The float value is the number of days since 1 January 1900.
>> > But for some reason you need to subtract 2 days to get it correct. See
>> > alsohttp://www.ozgrid.com/Excel/ExcelDateandTimes.htm(there you can
>> > read that MS counts 29 Feb 1900, but that date does not exist, what
>> > partly explains the subtraction).
>>
>> can you send me a spreadsheet file which causes this error? If it is a
>> date
>> field roo should also return a Date object.

I have fixed this problem. Replace the excelx.rb file in your gem with
the attached file.

-Thomas

excelx.rb

PAV

unread,
May 24, 2011, 2:58:19 AM5/24/11
to ruby-roo
Hi Thomas

Thanks a lot !

Best Regards,
Pascal

On 23 mei, 20:38, Thomas Preymesser <tho...@gmail.com> wrote:
> Hello,
>
> On 2011-05-21, PAV <pascal.verlin...@gmail.com> wrote:
>
> >> > I found a way to fix this problem. The float value that roo returns
> >> > seems to correspond with the internal float value that Excel is using
> >> > for dates. The float value is the number of days since 1 January 1900.
> >> > But for some reason you need to subtract 2 days to get it correct. See
> >> > alsohttp://www.ozgrid.com/Excel/ExcelDateandTimes.htm(thereyou can
> >> > read that MS counts 29 Feb 1900, but that date does not exist, what
> >> > partly explains the subtraction).
>
> >> can you send me a spreadsheet file which causes this error? If it is a
> >> date
> >> field roo should also return a Date object.
>
> I have fixed this problem. Replace the excelx.rb file in your gem with
> the attached file.
>
> -Thomas
>
> --
> Thomas Preymesser
> tho...@gmail.comhttp://thopre.googlepages.com/http://thopre.wordpress.com/
>
>  excelx.rb
> 25KWeergevenDownloaden
Reply all
Reply to author
Forward
0 new messages