Forum: Ruby Count Coulmns in Excel file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ganesh G. (Guest)
on 2008-12-04 10:45
Hi,
  How to count the number of columns in an excel file....
and i am using "Spreadsheet::ParseExcel" gem to parse the excel file

if anybody knows plz reply me

advanced thanks
Ganesh
Craig D. (Guest)
on 2008-12-04 15:57
(Received via mailing list)
I don't know how to do this, but maybe you can find something on the
Ruby on
Windows blog in the articles related to Excel.

http://rubyonwindows.blogspot.com/search/label/excel

Regards,
Craig
Hannes W. (Guest)
on 2008-12-05 16:35
Ganesh G. wrote:
>   How to count the number of columns in an excel file....
> and i am using "Spreadsheet::ParseExcel" gem to parse the excel file

the ParseExcel-Gem is deprecated - please use its shiny new replacement:
gem install spreadsheet

and use Worksheet#dimensions:
http://spreadsheet.rubyforge.org/classes/Spreadshe...

hth

cheers
Hannes
Thomas P. (Guest)
on 2009-01-11 03:00
(Received via mailing list)
2008/12/4 Ganesh G. <removed_email_address@domain.invalid>:
> Hi,
>  How to count the number of columns in an excel file....
> and i am using "Spreadsheet::ParseExcel" gem to parse the excel file
>
> if anybody knows plz reply me

in my 'roo' gem (http://rubyforge.org/projects/roo/):
---------
require 'rubygems'
require 'roo'

s = Excel.new("test/numbers1.xls")
s.default_sheet = s.sheets.first
puts "first column: #{s.first_column}"
puts "last column: #{s.last_column}"
puts "number of non empty colums: #{s.last_column-s.first_column+1}"
puts "number of colums from 'A' to last column: #{s.last_column}"
-----------

-Thomas
This topic is locked and can not be replied to.