如何使用 py-appscript 创建 Excel 图表?
我正在使用 Excel 2011 v14 并尝试根据工作表上的选定范围动态创建图表。为了选择范围,我使用以下代码段:
xl = app('Microsoft Excel')
tcell = 'B'
qcell = 'C'
for r in xrange(2, 16):
xl.cells[tcell + str(r)].value.set(r)
xl.cells[qcell + str(r)].value.set(random.randint(2, 100))
xl.cells["B2:C15"].select()
xl.make(new=k.chart, at=xl.active_sheet)
但我在活动工作表上得到了一个空白图表。任何帮助将不胜感激。
I am using Excel 2011 v14 and trying to dynamically create a chart based on the selected range on my worksheet. To select a range, I use the following code segment:
xl = app('Microsoft Excel')
tcell = 'B'
qcell = 'C'
for r in xrange(2, 16):
xl.cells[tcell + str(r)].value.set(r)
xl.cells[qcell + str(r)].value.set(random.randint(2, 100))
xl.cells["B2:C15"].select()
xl.make(new=k.chart, at=xl.active_sheet)
but I got a blank chart on the active sheet. Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如我向其他有类似问题的人建议的 ,您应该首先弄清楚如何在本机 Applescript 中实现此功能,然后移植到 py-appscript。您的代码片段中可能会出现很多错误,并且 Applescript 可能(而且通常是)返回框架不会一路返回给您的错误。
As I suggested to someone else who had a similar question, you should sort out how to make this work in native Applescript first and then port to py-appscript. There is a lot that can go wrong in your code snippet and there could be (and usually are) errors being returned by Applescript that the framework doesn't carry all the way back to you.