Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Fit Columns To Data

Hello.

I know about "Fit Columns To Data" function in the straight table context menu.

But is there a macro function for that?

Thank you.

2 Replies
Not applicable
Author

You can use something like this:

set mybox = ActiveDocument.ActiveSheet.CreateTableBox
mybox.AddField "Class"
mybox.AddField "ClassComment"
set tbp = mybox.GetProperties
tbp.Layout.ColLayouts.Item(0).ColWidth = 200
tbp.Layout.ColLayouts.Item(1).ColWidth = 400
mybox.SetProperties tbp


Instead of 200 and 400 you can calculate a maximum length for the columns.

Not applicable
Author

No

I want to have an autofit depending on length of data in fields just like the manual "Fit Columns To Data" function.

UPD: Ah, sorry. You mean to calculate the maximum length before formating table layout. Yes, thank you, I'll try this.

But I hoped there is simplier way 😞