我试图通过在Iron Python脚本中指定限制条件将数据导出到excel。单击Action Control - Button时,应将满足限制条件的数据导出为excel。下面是即使指定了限制条件,也要将完整数据写入excel的代码。
请协助我限制导出到excel的数据。
先谢谢您的澄清。
#from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers
from System.IO import File, Directory
from System.Collections.Generic import List
# directory
if not Directory.Exists("C:\Users\47586\Documents\Daily activities\POC"):
Directory.CreateDirectory("C:\Users\47586\Documents\Daily
activities\POC")
if Document.Data.Tables["Test"].Columns["Sales"] > 200:
table = Document.ActiveDataTableReference
names = ['Country_Name','Sales']
allRows =
Document.Data.AllRows.GetSelection(table).AsIndexSet()
writer =
Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter)
# columns
stream = File.OpenWrite("C:\Users\47586\Documents\Daily
activities\POC\Filename.xls")
allColumnNames = List[str]()
writer.Write(stream, table, allRows,names)
stream.Close()
stream.Dispose()
#######################################################################
由于 圣
答案 0 :(得分:0)
from Spotfire.Dxp.Data import *
from System.Collections.Generic import List
from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers
from System.IO import File, Directory
table = Document.Data.Tables["Test"]
rowSelection=table.Select("Sales=200")
#Limiting and Column Declaration
names = ['Customer_Name','Sales']
allRows = rowSelection.AsIndexSet()
writer =
Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter)
stream = File.OpenWrite("C:\Users\Desktop\export.xls")
allColumnNames = List[str]()
writer.Write(stream, table, allRows,names)
stream.Close()
stream.Dispose()