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?
Asked
Active
Viewed 2,686 times
1
-
What is your problem, what do you have tried? – BendEg Dec 17 '15 at 12:47
-
http://stackoverflow.com/questions/31731159/script-to-export-spotfire-graphic-to-powerpoint – Jacek Sierajewski Dec 17 '15 at 16:59
1 Answers
2
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

Jacek Sierajewski
- 613
- 1
- 11
- 33
-
This soluition works great on the client, but not on WebPlayer and I am not sure if there is any solution that will. Perhaps by installing PPT on the server, open it via the MS Interop namespace and save it somewhere on the server for download. – jleviaguirre Dec 17 '15 at 17:33
-
So it should be related to how you host the WebPlayer and if it has access to referenced library. To troubleshoot this we would have to start with error msg. I didnt try this in WebPlayer I must admit. – Jacek Sierajewski Dec 18 '15 at 09:17