Jump to content

This is regarding Tibco Spotfire


Ankita Bhattacharjee

Recommended Posts

Hi All,

 

This is regarding Tibco Spotfire. I was trying to export data table to an excel file using IronPython scripting. The script I am using is:

 

from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers

from System.IO import File

writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter)

filtering = Document.ActiveFilteringSelectionReference.GetSelection(table).AsIndexSet()

stream = File.OpenWrite("SpotfireExport.xls")

names = []

for col in table.Columns:

names.append(col.Name)

writer.Write(stream, table, filtering, names)

stream.Close()

 

Now the above script is working fine in Spotfire client, but when I am using the web player version the functionality is not working. I think I have to mention the download path and then download the excel file through the script.

Can anyone have any idea on how to do that

 

Thanks in advance,

Ankita

Link to comment
Share on other sites

  • 1 month later...

Hello Ankita,

Below is an Sample code that should work on both Client and Web Player. When you execute the script on WebPlayer the file is exported to the Spotfire Export folder under Web Player server .

===============================

from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers

from System.IO import File, Directory

from System.Collections.Generic import List

table = Document.ActiveDataTableReference

writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter)

allRows = Document.Data.AllRows.GetSelection(table).AsIndexSet()

# directory

if not Directory.Exists("C:\Spotfire_Export"):

Directory.CreateDirectory("C:\Spotfire_Export")

names = []

# columns

stream = File.OpenWrite("C:\Spotfire_Export\Filename.xls")

allColumnNames = List[str]()

for column in table.Columns:

allColumnNames.Add(column.Name)

writer.Write(stream, table, allRows, allColumnNames)

stream.Close()

stream.Dispose()

=============================

Link to comment
Share on other sites

  • 2 years later...

Hello Shandilya Peddi

 

Thanks for the example. However, the export result ("C:\Spotfire_Export\Filename.xls") has zero records of the data file "table"

 

Is this maybe due to the fact that my table is a on-demand table The on-demand table has been retreived and show clearly multiple records in the visualization, but my export (Excel) has only the headers and no details.

 

Could you help me here

 

Kind regards

 

Peter Bij

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...