Skip to content

Instantly share code, notes, and snippets.

@jschementi
Created August 1, 2009 22:40
Show Gist options
  • Save jschementi/159829 to your computer and use it in GitHub Desktop.
Save jschementi/159829 to your computer and use it in GitHub Desktop.
require 'win32ole'
# Creates OLE object to Excel
excel = WIN32OLE.new("excel.application")
# Create the chart
excel['Visible'] = true
workbook = excel.Workbooks.Add
excel.Range("a1")['Value'] = 3
excel.Range("a2")['Value'] = 2
excel.Range("a3")['Value'] = 1
excel.Range("a1:a3").Select
excelchart = workbook.Charts.Add
# -4100 is the value for the Excel constant xl3DColumn.
excelchart['Type'] = -4100;
# This is the cool part! Rotate the chart ...
30.step(180, 10) do |rot|
excelchart['Rotation'] = rot
end
excel.ActiveWorkbook.Close(0)
excel.Quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment