问题描述
我正在使用代码将 Spotfire 中的视觉效果输出到 PowerPoint 演示文稿,如下所示。它目前正在关闭传说,因为它们经常开始重叠并变得难以辨认。我想知道在使用 python 将它们导出到 PowerPoint 时是否有某种方法可以控制图例的外观。我使用的 Spotfire 版本是 7.11。
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=False
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=False
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,600,400)
title=slide.Shapes.Title
txt=slide.Shapes.AddTextBox(1,10,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
感谢您的帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)