简体   繁体   English

如何仅使用IronPython脚本导出Spotfire所选列?

[英]How to export only Spotfire Selected columns with IronPython script?

I use a working IronPython script to export in an xls file all the columns of a Spotfire Table. 我使用有效的IronPython脚本在xls文件中导出Spotfire表的所有列。

I want to update the below script to only export “Selected columns” (see picture) defined in the Column menu of the Table Properties. 我想更新以下脚本以仅导出在表格属性”的“列”菜单中定义的“选定列” (参见图片)。

With more than 1500 columns among 50 tables it is not an option to hard coded/predefined the list of column to be exported. 50个表中有1500多个列,因此不能硬编码/预定义要导出的列的列表。 If I change the columns selection in the Table Properties only those selected column must be exported. 如果更改“表属性”中的列选择,则仅必须导出那些选择的列。

选定的列

In the example I would like to have in my Test.xls file only content of the three columns “studyid”, “etcd” and “element” of my TE table. 在该示例中,我想在我的Test.xls文件中仅包含TE表的三列“ studyid”,“ etcd”和“ element”的内容。

With the below script “domain” and “tesrcdtc” column are also exported. 使用以下脚本,“域”和“ tesrcdtc”列也将导出。

IronPython script: 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.

相关问题 仅导出PHP中的选定列 - Export only selected columns in php 仅从数据表中导出选定的列 - Export from datatable only selected columns 如何仅导出django admin中的选定记录? - How to export ONLY selected records in django admin? 如何仅使用命令行从oracle数据库导出选定的函数,选定的过程,选定的视图和选定的表? - How to export selected functions, selected procedures, selected views and selected tables only from oracle database using command line? Spotfire可视化文件的最高质量导出是什么? - What is the highest quality export for Spotfire visualizations? CSV导出脚本仅在IE中生成错误? - CSV Export Script only generates error in IE? 如何导出所有应该只有可见列的jqgrid数据,而不管分页 - how to export all jqgrid data which should have only visible columns irrespective of paging 如何仅将 Laravel Blade 表视图中的特定列导出到 Ecxel 文件? - How Export only specific columns from Laravel Blade table view to Ecxel file? IntelliJ 数据库:如何仅将更改的表行导出到更新的 SQL 脚本? - IntelliJ Database: How to export only changed table rows to an update SQL script? 在magento面板管理员中仅导出到Excel选定的行 - Export to Excel only selected rows in magento panel admin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM