Jump to content

How to export my Spotfire dashboard Visuals in PPT format by using script (Power point)


Recommended Posts

Hi Everyone? 

I want to use a script to add a Button for Export Power point slides pf my Spotfire dashboard, I know that Spotfire is providing an Option for Export Pdf and Export Power Point (File-> Menu Bar),

Somehow users are unable to access menu bar in Web Player, We have to write a Script to add this functionality. 

 

Could you please help me on this? 

Thanks in Advance . 

Link to comment
Share on other sites

Hi Nagarajareddy,

If users are unable to see the Menu bar, it may have been hidden from them. One of the privileges that can be granted to users, is the Export to PowerPoint one:
image.thumb.png.4e3c631ac331e7a7efecf9bb7fec5a98.png

If this is not granted, users will not be able to see the menu option for the PowerPoint export.

If, for some reason, it is not possible to fix that, then a script could be the solution. You can find an iron python example script here. You may need to tweak that script, according to the Spotfire version in use.

Kind regards,

David

Link to comment
Share on other sites

Hi @David Boot-Olazabal Thanks for your prompt response, My users don't access the dashboards through Web player, They have their own Platform (Commerce) which is integrated with Spotfire, They are accessing  the dashboards through commerce, So when they are trying to access through commerce Spotfire Menu bar will not show due to commerce is having different UI setup , So we have only option to use script, I found a script for Export PDF, Its working fine but unable to get a script for Export Power point, I was tried whatever available in Online, I am tried my best but couldn't achieve, 

Could you please share your inputs? 

Thank you. 

 

 

 

Link to comment
Share on other sites

Hi Nagarajareddy,

My bad, I referenced a wrong page in my first reply.

Regarding the user set up, yes, it makes sense that they don't have the menu bar available since it is embedded in a different application.

I have found this code, which exports the visualizations on the page. It works from the Analyst client, if you uncheck the image.png.c79d94f8cfae44682c81525d8ab04413.png box.

import clr
clr.AddReference("System.IO")
from System.IO import *
from Spotfire.Dxp.Application.Visuals import VisualContent
from System.Drawing import Bitmap, Graphics, Rectangle, Point
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

Kind regards,

David

Link to comment
Share on other sites

  • 2 months later...
On 5/7/2024 at 11:54 AM, David Boot-Olazabal said:

Hi Nagarajareddy,

My bad, I referenced a wrong page in my first reply.

Regarding the user set up, yes, it makes sense that they don't have the menu bar available since it is embedded in a different application.

I have found this code, which exports the visualizations on the page. It works from the Analyst client, if you uncheck the image.png.c79d94f8cfae44682c81525d8ab04413.png box.

import clr
clr.AddReference("System.IO")
from System.IO import *
from Spotfire.Dxp.Application.Visuals import VisualContent
from System.Drawing import Bitmap, Graphics, Rectangle, Point
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

Kind regards,

David

This script exports one visual per slide, is it possible to export the active page in one slide?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...