Nikita Belooussov Posted February 16, 2021 Share Posted February 16, 2021 Hi I am using the codeto output visuals in Spotfire to a PowerPoint presentation, it can be seen below. It is currently turning off the legends, due to them often starting to overlap and becoming illegible. I was wondering if there is some way to control the appearance of the legend when exporting them to the PowerPoint using python. The Spotfire version I am using is 7.11. Thanks for the help import clr from System import * from System.IO import * clr.AddReference("System.Windows.Forms") from System.Windows.Forms import FolderBrowserDialog,MessageBox from Spotfire.Dxp.Application import Visual from Spotfire.Dxp.Application.Visuals import * from System.Drawing import Bitmap, Graphics, Rectangle, Point from System.IO import Path from Spotfire.Dxp.Application.Visuals import VisualContent clr.AddReference("Microsoft.Office.Interop.PowerPoint") import Microsoft.Office.Interop.PowerPoint as PowerPoint from random import randint filename="" folder=FolderBrowserDialog() result=folder.ShowDialog() if result==result.OK: filename=folder.SelectedPath else: MessageBox.Show("Please select a folder and try again") id=randint(10000000, 50000000) w=800 h=600 bm = Bitmap(w,h) g = Graphics.FromImage(bm) r = Rectangle(Point(0,0), bm.Size) test="True" if powerPointSel=="all": for d in Document.Pages: Document.ActivePageReference=d for visual in Document.ActivePageReference.Visuals: if visual.TypeId!=VisualTypeIdentifiers.Table and visual.TypeId!=VisualTypeIdentifiers.HtmlTextArea: rt=visual.As[VisualContent]() rt.Legend.Visible=True charttitle= rt.Title charttitle=charttitle.replace("/","") tb=visual.As[VisualContent]().Render(g,r) tempFilename = filename + "\" + str(id)+charttitle + ".jpeg" bm.Save(tempFilename) if powerPointSel=="current": for visual in Document.ActivePageReference.Visuals: if visual.TypeId!=VisualTypeIdentifiers.Table and visual.TypeId!=VisualTypeIdentifiers.HtmlTextArea: rt=visual.As[VisualContent]() rt.Legend.Visible=True charttitle= rt.Title charttitle=charttitle.replace("/","") tb=visual.As[VisualContent]().Render(g,r) tempFilename = filename + "\" + str(id)+charttitle + ".jpeg" bm.Save(tempFilename) files=Directory.GetFiles(filename) powerpoint = PowerPoint.ApplicationClass() powerpoint.Visible = True pres=powerpoint.Presentations.Add() for f in files: if str(id) in f: slide=pres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly) slide.Shapes.AddPicture(f, False, True, 100, 100, 600, 400) title=slide.Shapes.Title txt=slide.Shapes.AddTextBox(1,10,500,500,100) txt.TextFrame.TextRange.Text="Enter Comments here.............." #title2.Top=.3 title.Top=0.1 obj=slide.Shapes.Title.TextFrame.TextRange f=f.split("\") f=f.pop() f=f.replace(".jpeg","") obj.Text=f.replace(str(id),'') obj.Font.Size=32 if powerPointSel=="all": for d in Document.Pages: Document.ActivePageReference=d for visual in Document.ActivePageReference.Visuals: if visual.TypeId!=VisualTypeIdentifiers.Table and visual.TypeId!=VisualTypeIdentifiers.HtmlTextArea: rt=visual.As[VisualContent]() rt.Legend.Visible=True if powerPointSel=="current": for visual in Document.ActivePageReference.Visuals: if visual.TypeId!=VisualTypeIdentifiers.Table and visual.TypeId!=VisualTypeIdentifiers.HtmlTextArea: rt=visual.As[VisualContent]() rt.Legend.Visible=True 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