Jump to content

Export to Excel only filtered rows using Ironpython


Andreas Karagiannis

Recommended Posts

I am trying to use Ironpython to have a button export my table to excel with only the S/N and comments Columns. When I enter a value into the input box I want to export the selected row and comments into excel.

 

this is the code I used

 

from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers

from System.IO import File, Directory

from System.Collections.Generic import List

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Visuals import *

DataTable = Document.ActiveDataTableReference

Rows = Document.ActiveFilteringSelectionReference.GetSelection(DataTable).AsIndexSet()

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

stream = File.OpenWrite("C:\Users\akaragiaDesktop\Comments\SHOP_ORDER (Illuminator).xls")

Cols = ["SFC", "Comments"] # pulls in SFC Column

writer.Write(stream, DataTable, Rows, Cols)

stream.Close()

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