Class: ExcelToCsv::WinExcel
- Inherits:
-
ExcelAppWrapper
- Object
- ExcelAppWrapper
- ExcelToCsv::WinExcel
- Defined in:
- lib/exceltocsv/win_excel.rb
Instance Method Summary collapse
- #close_workbook ⇒ Object
- #open_workbook(filepath) ⇒ Object
- #worksheet_data(worksheet_name) ⇒ Object
- #worksheet_names ⇒ Object
Instance Method Details
#close_workbook ⇒ Object
33 34 35 36 |
# File 'lib/exceltocsv/win_excel.rb', line 33 def close_workbook # Close Excel @xl.Quit end |
#open_workbook(filepath) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# 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) ⇒ Object
38 39 40 |
# File 'lib/exceltocsv/win_excel.rb', line 38 def worksheet_data(worksheet_name) data = @wb.Worksheets(worksheet_name).UsedRange.Value end |
#worksheet_names ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/exceltocsv/win_excel.rb', line 25 def worksheet_names worksheets = [] @wb.Worksheets.each do |ws| worksheets << ws.Name end worksheets end |