M
Moran, Craig M (BAH)
Has anyone successfully used Ruby to sort an Excel spreadsheet? It has been
said that VBScript usually translates directly to Ruby if you're using
WIN32OLE. For the most part, I have found this to be true. However, this
example translated from VBScript fails on the Sort line:
#/usr/bin env ruby
require 'win32ole'
excel = WIN32OLE.new("excel.application")
excel['Visible'] = TRUE
spreadsheet =
excel.Workbooks.Open("C:\\Path\\to\\your\\spreadsheet\\Spreadsheet.xls")
sheet = spreadsheet.Worksheets(1)
sheet.Cells.Select
sheet.Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
How would one translate this to Ruby? If you comment out the Sort line,
Ruby will succeed in running to the Cells.Select point.
v/r-
Craig
said that VBScript usually translates directly to Ruby if you're using
WIN32OLE. For the most part, I have found this to be true. However, this
example translated from VBScript fails on the Sort line:
#/usr/bin env ruby
require 'win32ole'
excel = WIN32OLE.new("excel.application")
excel['Visible'] = TRUE
spreadsheet =
excel.Workbooks.Open("C:\\Path\\to\\your\\spreadsheet\\Spreadsheet.xls")
sheet = spreadsheet.Worksheets(1)
sheet.Cells.Select
sheet.Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
How would one translate this to Ruby? If you comment out the Sort line,
Ruby will succeed in running to the Cells.Select point.
v/r-
Craig