Thanks for all comments. I usually use the win32ole to work with the
excel object. I just thought for some tasks sequel looked nice and
concise.
One way without sequel:
require 'win32ole'
conn_string = 'Provider=Microsoft.Jet.OLEDB.4.0;'
conn_string << 'Data Source=C:\mydata\my_file.xls;'
conn_string << 'Extended Properties=Excel 8.0;'
connection = WIN32OLE.new('ADODB.Connection')
connection.Open(conn_string)
recordset = WIN32OLE.new('ADODB.Recordset')
sql="SELECT * FROM cam;"
recordset.Open(sql, connection)
data = recordset.GetRows.transpose
p data
connection.close
outputs:
[[1.0, "north"], [2.0, "south"], [3.0, "east"], [4.0, "west"]]
My original soulution set up a dsn. As a new reporting period rolls
over, the files are archived in a new path. With the locations
changing, I just didn't want to go thru the admin panel to change the
dsn.
Is it possible to get similar connection with DB=Sequel.ado()?
The odbc worked really nice:
require 'rubygems'
require 'sequel'
DB=Sequel.odbc('my_odbc_for_excel')
dataset=DB[:cam]
dataset.all.each{|r| p r}
outputs:
{:names=>"north", :loc=>1.0}
{:names=>"south", :loc=>2.0}
{:names=>"east", :loc=>3.0}
{:names=>"west", :loc=>4.0}
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---