Guest User

Untitled

a guest
May 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. ## LoadDataTest.rb
  2. # K:\_Projects\Ruby\_Rails_Apps\PayrollLoader
  3. require 'win32ole'
  4. csvFile = DATA.read.chomp
  5. puts csvFile, ""
  6.  
  7. excel = WIN32OLE.new('Excel.Application')
  8. # Previously, tried: F:\Docume~1\AllUse~1\StartM~1\Programs\_Microsoft\Micros~3\Micros~2.lnk
  9. puts "", "==== Get Excel methods ====", ""
  10. puts excel.ole_get_methods # -- worked fine also
  11. # Displays "open" method:
  12. puts "", "==== Get Excel methods ~ /Op/ ====", ""
  13. excel.ole_methods.each { |meth| puts meth if meth.to_s =~ /Op/i } # -- returned nothing
  14. # Try to find an "open" method by sorting methods:
  15. puts "", "==== Get Excel methods, sorted ====", ""
  16. # puts (excel.ole_methods.each { |meth| meth.to_s}).sort
  17. puts "Failed with: undefined method `<=>' for ShortcutMenus:WIN32OLE_METHOD (NoMethodError)"
  18. puts "", "==== Get Excel methods, sorted more simply====", ""
  19. puts excel.methods.sort # -- worked fine
  20. puts "", "==== Try opening a CSV file ====", ""
  21. system( "csvFile" ) # Couldn't open the document
  22. puts "system(\"csvFile\") returned nothing"
  23. puts "==== EOJ ===="
  24. __END__
  25. K:\_Projects\Ruby\_Rails_Apps\PayrollLoader\TestSheet.csv
Add Comment
Please, Sign In to add comment