[英]How to export only Spotfire Selected columns with IronPython script?
我使用有效的IronPython脚本在xls文件中导出Spotfire表的所有列。
我想更新以下脚本以仅导出在“表格属性”的“列”菜单中定义的“选定列” (参见图片)。
50个表中有1500多个列,因此不能硬编码/预定义要导出的列的列表。 如果更改“表属性”中的列选择,则仅必须导出那些选择的列。
在该示例中,我想在我的Test.xls文件中仅包含TE表的三列“ studyid”,“ etcd”和“ element”的内容。
使用以下脚本,“域”和“ tesrcdtc”列也将导出。
IronPython脚本:
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:/Export/Test.xls")
Cols = []
for col in DataTable.Columns:
Cols.append(col.Name)
writer.Write(stream, DataTable, Rows, Cols)
stream.Close()
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:/Export/Test.xls")
Cols = [“studyid”,“etcd”,“element”] # Instead of adding all the columns, just add the ones you want
writer.Write(stream, DataTable, Rows, Cols)
stream.Close()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.