Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer



If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

extract csv data from visualization

#get list of filtered rows
dataTable = Document.ActiveDataTableReference
rows = Document.ActiveFilteringSelectionReference.GetSelection(dataTable).AsIndexSet()

#Script configuration
delim = ","
rowDelim = "\n"
docProperty = "myDocProperty"

#generate CSV
csv = ""
for column in dataTable.Columns:
   csv += column.Name + delim

csv += rowDelim

for r in rows:
   for column in dataTable.Columns:
      csv += column.RowValues.GetFormattedValue(r) + delim
   csv+=rowDelim

#show results
print csv

1 comment:

Anonymous said...

How would you prompt the user to specify a file name or to create a file with a name given properties from the file (e.g. Report1_as_of_Date(DateTimeNow())_for_period_p$StartDate_to_p$EndDate.csv