require 'phi'; include Phi
require 'rdb'; include RDB
require 'com' # CoInitialize

form = Form.new

data_set = ADODataSet.new
data_set.connection_string =
    'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\md6code\16\Excel' +
    '\ABCCompany.xls;Mode=Share Deny None;Extended Properties=Excel 8' +
    '.0;Persist Security Info=False'
data_set.cursor_type = CT_STATIC
data_set.command_text = 'Employees$'
data_set.command_type = CMD_TABLE_DIRECT

data_source = DataSource.new
data_source.data_set = data_set

grid = DBGrid.new form
grid.data_source = data_source
grid.align = AL_CLIENT
grid.on_dbl_click = proc do
  p data_set.fields.count
  data_set.active = true
  p data_set.fields.count
  data_set.fields.each{|field| field.display_width = 20 }
end

form.show
Phi.mainloop
