如何从 AppleScript 操作和打印 MS Excel 中的图表?

发布于 2024-09-01 13:02:49 字数 1154 浏览 3 评论 0原文

对于 MS Excel for Mac 2008 中的现有图表,在 AppleScript 中,我尝试做两件事:

  1. 将 3D 图表旋转 1°
  2. 将图表另存为图像 (png)

从我在 Intertubes 上找到的内容来看,似乎可能的。但 AppleScript 的尴尬冗长和网络上缺乏重要的 MS Excel AppleScript 示例对我来说是难以克服的。

只是为了保存部分,这就是我到目前为止所得到的:

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

“旋转 1°”任务似乎涉及“内部对象”,但这只是我所得到的。我所说的“旋转”是指旋转图表对象本身,而不是图像。这可以通过“设置图表格式”对话框来完成... MS Excel 对话框 http://dietpizza.ch/images/ 3d-rotation-ms-excel-dialog-box.png

通过操纵此值,图表对象会发生如下两个图像所示的变化。 (15° 效果)

MS Excel 3D 图形示例 0 http://dietpizza.ch/图片/3d-rotation-0.png MS Excel 3D 图形示例 1 http://dietpizza.ch/images/3d-rotation- 1.png

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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街道布景 2024-09-08 13:02:49

通过设置图表对象chart属性的rotation属性,可以通过AppleScript更改图表的X轴旋转。

下面的 AppleScript 应该可以解决这个问题:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文