return fso.GetAbsolutePathName(filename) end filename = getAbsolutePath(ARGV[0]) xl = WIN32OLE.new('Excel.Application') book = xl.Workbooks.Open(filename) begin book.Worksheets.each do |sheet| sheet.UsedRange.Rows.each do |row| record = [] row.Columns.each do |cell| record << cell.Value end puts record.join(",") end end ensure book.Close xl.Quit end C:¥Users¥k-ohtani>Desktop C:¥Users¥k-ohtani¥Desktop>ruby to_csv.rb Book1.xlsx C:¥Users¥k-ohtani¥Desktop>ruby to_csv.rb Book1.xlsx > Book1.csv