class ExcelToCsv::WinExcel
Constants
- DisplayAlerts
Public Instance Methods
close_workbook()
click to toggle source
# File lib/exceltocsv/win_excel.rb, line 33 def close_workbook # Close Excel @xl.Quit end
open_workbook(filepath)
click to toggle source
# File lib/exceltocsv/win_excel.rb, line 14 def open_workbook(filepath) # Open an Excel file @xl = WIN32OLE.new('Excel.Application') # Turn off excel alerts. @xl.DisplayAlerts = false # 2nd param of false turns off the link update request # when an xls file is opened that contains links. @wb = @xl.Workbooks.Open("#{filepath}", false) end
worksheet_data(worksheet_name)
click to toggle source
# File lib/exceltocsv/win_excel.rb, line 38 def worksheet_data(worksheet_name) data = @wb.Worksheets(worksheet_name).UsedRange.Value end
worksheet_names()
click to toggle source
# File lib/exceltocsv/win_excel.rb, line 25 def worksheet_names worksheets = [] @wb.Worksheets.each do |ws| worksheets << ws.Name end worksheets end