简体   繁体   中英

How to export a Tibco Spotfire report in PPT file on the Action Button Click

I want to export a Tibco Spotfire report in PPT format as user clicks on the Button. Is there any IronPython script which can do this as action fires?

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 Adjusted from code found here: https://tibbr.tibcommunity.com/tibbr/#!/messages/69369

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM