Yacine El Gharbi Posted February 19, 2019 Share Posted February 19, 2019 Hi! I'm working on exporting visualizations from Spotfire to a ppt file using Ironpython. I used the following script and it's actually working. Although I'm trying to export those images to an existing ppt template and in reserved image fields. I hope you can help me do the necessary modifications on my script. Thanks!from System.Drawing import Bitmap, Graphics, Rectangle, Pointfrom Spotfire.Dxp.Application.Visuals import VisualContentfrom System.IO import Pathimport clr clr.AddReference("Microsoft.Office.Interop.PowerPoint")import Microsoft.Office.Interop.PowerPoint as PowerPoint##################### Powerpoint setuppowerpoint = PowerPoint.ApplicationClass()powerpoint.Visible = Truepres=powerpoint.Presentations.Add()slideCounter = 1##################### image properties obtained from properties entries (can be hard coded)width = int(Document.Properties["myWidth"])height = int(Document.Properties["myHeight"])################### obtain_image() - takes in 1 parameter (visualization handle)def obtain_image(viz):#file = "c:\tmp\test.jpg" # 'tmp' directory needs to exist file = Path.GetTempFileName() # obtain image vc = viz.As[VisualContent]() bm = Bitmap(width, height) g = Graphics.FromImage(bm) r = Rectangle(Point(0,0), bm.Size) vc.Render(g, r) bm.Save(file) addToSlide(file)################### # addToSlide - takes 1 parameter (filename)def addToSlide(file): global slideCounter #pp setup slide=pres.Slides.Add(slideCounter, PowerPoint.PpSlideLayout.ppLayoutBlank) slideCounter = slideCounter+1 slide.Shapes.AddPicture((file), False, True, Left=0, Top=10, Width=-1, Height=-1)################## # main part of programfor page in Document.Pages: print page.Title for visual in page.Visuals: if (visual.TypeId.ToString().find("Html") < 0): print "t",visual.Title,": ", visual.TypeId.ToString() obtain_image(visual) Link to comment Share on other sites More sharing options...
Sayali Patil Posted February 21, 2019 Share Posted February 21, 2019 Hello, There is an open method available for the Microsoft Presentations module which you might want to try ,to open an existing ppt and add to it - https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/ff763759(v%3Doffice.14) Link to comment Share on other sites More sharing options...
Yacine El Gharbi Posted February 22, 2019 Author Share Posted February 22, 2019 Thank you Sayali but I'm trying to write the script with ironpython! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now