Dariusz Wjcik Posted May 2, 2016 Share Posted May 2, 2016 Hi Is there any possibility to config or change by IronPython the default file name when exporting a table or cross table visualisation to excel via WebPlayer My client is complainign that the file name is generated after DXP file name by default. Link to comment Share on other sites More sharing options...
Peter Bij Posted January 31, 2020 Share Posted January 31, 2020 Hi, I use this part to let the end-user select destination and file name for an export function: #Load Modules from Spotfire.Dxp.Data import DataType, DataValue, DataRowReader, DataRow, IndexSet from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers from Spotfire.Dxp.Application.Visuals import VisualContent from System.IO import File, Directory, FileStream, FileMode from System.Collections.Generic import List from datetime import datetime import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import SaveFileDialog # For exclusive FileName, retrieve the current date and store it in a variable. #DateTimestamp is used to create unique filename now = datetime.now() DateTimeOfExport = now.strftime(" %Y-%m-%d-%H-%M-%S") # ------------------------------------------------------------- # -- Start of Dialog ----------------------------------------------------- #Set FileName for export destination, End-user selectable via ShowDialog #Preset Destination folder and name from Textbox inputbox "folderName" and "ExportFileName" folderName = Document.Properties["folderName"] ExportFileName = Document.Properties["ExportFileName"] ExportFileName = ExportFileName+ " " +Document.ActiveDataTableReference.Name +" " + DateTimeOfExport # Set Dialog parameters ExportFile = SaveFileDialog() ExportFile.Title = "Export data to Excel" ExportFile.Filter = "Spotfire Export Format (*.xlsx)|*.xlsx" #Set filename in dialog ExportFile.FileName = ExportFileName; ExportFile.ShowDialog() #put result from Showdialog in variable ExportFileName = ExportFile.FileName # -- End of Dialog ----------------------------------------------------- # -- Start of FileSystem checks ---------------------------------------- if ExportFile.FileName=="": # user does not select a file (cancel button) ExportFile = "" else: ExportFile = ExportFile.FileName # not strictly neccesary, but helpful during development print "saveFilename=", ExportFile print table.Name, "Row Count= ",table.RowCount, Selection # directory if not Directory.Exists(folderName): Directory.CreateDirectory(folderName) # -- End of FileSystem checks ------------------------------------------ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now