将Spotfire图形导出到PowerPoint的脚本 [英] Script to Export Spotfire Graphic to PowerPoint

查看:61
本文介绍了将Spotfire图形导出到PowerPoint的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将活动页面导出到现有的PowerPoint演示文稿.我从标题栏中知道如何执行此操作,但是我想将其合并到我正在编写的IronPython代码中,这样我就可以一次制作几张幻灯片.

I am trying to export an active page to an existing PowerPoint presentation. I know how to do this from the title bar, but I would like to incorporate this into the IronPython code I am writing so I can do several slides at once.

谢谢, 约瑟夫

推荐答案

这将打开powerpoint并每页导出一个可视化文件:

This will open up powerpoint and export one visualisation per page:

from System.IO import *
from Spotfire.Dxp.Application.Visuals import VisualContent
from System.Drawing import Bitmap, Graphics, Rectangle, Point
import clr
clr.AddReference("Microsoft.Office.Interop.PowerPoint")
import Microsoft.Office.Interop.PowerPoint as PowerPoint

powerpoint = PowerPoint.ApplicationClass()
powerpoint.Visible = True
pres=powerpoint.Presentations.Add()
slideCounter = 1

for visual in Document.ActivePageReference.Visuals:
    #print visual.Title

    #export graphic to temp file
    vc = visual.As[VisualContent]()
    bm = Bitmap(2000, 1200)
    g = Graphics.FromImage(bm)
    r = Rectangle(Point(0,0), bm.Size)
    vc.Render(g, r)
    file = Path.GetTempFileName()
    bm.Save(file)

    #pp setup
    slide=pres.Slides.Add(slideCounter, PowerPoint.PpSlideLayout.ppLayoutTitleOnly)
    slideCounter = slideCounter+1
    slide.Shapes.AddPicture((file), False, True, 30, 60, 650, 400)
    title=slide.Shapes.Title
    txt=slide.Shapes.AddTextBox(1,10,500,500,100)
    title.Top=0.1
    obj=slide.Shapes.Title.TextFrame.TextRange
    obj.Font.Size=24

您可以使用以下方法遍历页面:

You can loop through pages with:

for page in Document.Pages:
    Document.ActivePageReference=page

根据此处找到的代码进行了调整: https://tibbr.tibcommunity.com/tibbr /#!/messages/69369

Adjusted from code found here: https://tibbr.tibcommunity.com/tibbr/#!/messages/69369

这篇关于将Spotfire图形导出到PowerPoint的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆