Difference between revisions of "Ruby and Windows Automation"

From PeformIQ Upgrade
Jump to navigation Jump to search
Line 4: Line 4:


=Functions=
=Functions=
Miscellaneous function in the API...
<pre>
excel = WIN32OLE.new('Excel.Application')
book = excel.Workbooks.Add()
sheet = book.Worksheets(1)
excel.Visible = true
range = sheet.Range('A1').Resize(data.size, data.first.size)
range.Value = data
sheet.Rows(1).AutoFilter()
</pre>
==iTunes==
<pre>
require 'win32ole'
app = WIN32OLE.new('iTunes.Application')
data = []
app.LibraryPlaylist.Tracks.each do |track|
  if not track.Podcast
    data << [track.Artist, track.Year, track.Album, track.Name]
  end
end
data.sort!
data.insert(0, ['ARTIST', 'YEAR', 'ALBUM', 'NAME'])
</pre>




[[Category:Ruby]]
[[Category:Ruby]]
[[Category:Microsoft Office Automation]]
[[Category:Microsoft Office Automation]]

Revision as of 09:40, 12 March 2010

References

Functions

Miscellaneous function in the API...

excel = WIN32OLE.new('Excel.Application')

book = excel.Workbooks.Add()

sheet = book.Worksheets(1)

excel.Visible = true

range = sheet.Range('A1').Resize(data.size, data.first.size)
range.Value = data

sheet.Rows(1).AutoFilter()


iTunes

require 'win32ole'

app = WIN32OLE.new('iTunes.Application')

data = []

app.LibraryPlaylist.Tracks.each do |track|
  if not track.Podcast
    data << [track.Artist, track.Year, track.Album, track.Name]
  end
end

data.sort!

data.insert(0, ['ARTIST', 'YEAR', 'ALBUM', 'NAME'])