Michael Kalada 2 Posted March 24, 2020 Share Posted March 24, 2020 Looking for a script that does the same thing as double clicking on a column header border I know we can use something likecol.Width = 75 but i have hundreds of columns to choose from, and sometimes the data will be small, other times long Link to comment Share on other sites More sharing options...
Shashank Gurnalkar Posted March 27, 2020 Share Posted March 27, 2020 To a certain extent, this script will help. from Spotfire.Dxp.Data import * from Spotfire.Dxp.Application.Visuals import * myTable = Document.Data.Tables["FILM"] tablePlot = vis.As[TablePlot] ()# vis is a script parameter for col in tablePlot.TableColumns: if str(col.DataColumn.DataType) != "String": continue myCursor = DataValueCursor.CreateFormatted(myTable.Columns[col.Name]) max_value=0 for row in myTable.GetRows(myCursor): max_value = max(max_value,len(myCursor.CurrentValue)) col.Width=6*max_value This will calculate the length of a maximum value present in the string column and assign the column width for that column in the multiples of maximum value (since column width is measured in pixels). This will change the width of the columns with data type as string since for other data types we do not really need to change the default width. If you want, you can modify it accordingly. 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