开发者

How to manipulate and print a chart in MS Excel from AppleScript?

开发者 https://www.devze.com 2022-12-30 05:26 出处:网络
With an existing chart in a MS Excel for Mac 2008, in AppleScript, I am trying to do two things: Rotate a 3D chart 1°

With an existing chart in a MS Excel for Mac 2008, in AppleScript, I am trying to do two things:

  1. Rotate a 3D chart 1°
  2. Save the chart as a image (png)

From what I've开发者_如何学JAVA found on the Intertubes, it seems possible. But AppleScript's awkward verbosity and the lack of non-trivial MS Excel AppleScript examples on the web are too much for me to overcome.

Just for the saving part, this is what I have so far:

tell application "Microsoft Excel"
    activate object worksheet "iozone-16"
    set cht to chart object 1 of active sheet
    tell cht
        #save as chart object [picture type enumeration] [file name Unicode text]
        #Argh!!! 
    end tell
end tell

The 'rotate 1°' task seems to involve "internal objects", but that is as far as I've gotten. By 'rotate', I mean to rotate the chart object itself, not the image. This can be done in with the Format Chart dialog box for ... MS Excel Dialog Box http://dietpizza.ch/images/3d-rotation-ms-excel-dialog-box.png

By manipulating this value, it the chart object changes as in below these next two images. (15° for effect)

MS Excel 3D graph example 0 http://dietpizza.ch/images/3d-rotation-0.png MS Excel 3D graph example 1 http://dietpizza.ch/images/3d-rotation-1.png


The X axis rotation of the chart can be changed via AppleScript by setting the rotation property of the chart property of the chart object.

The following AppleScript should do the trick:

set theImagePath to (path to desktop as text) & "Chart.png"

tell application "Microsoft Excel"
    set theChart to first chart object of first sheet
    set rotation of chart of theChart to 90
    save as picture theChart picture type save as PNG file file name theImagePath
end tell
0

精彩评论

暂无评论...
验证码 换一张
取 消