Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Auto "Fit Columns to Data" or with a extra button

There is a possibility in Qlikview to "Fit Columns to Data" from a straight table. But this need to be done by a rightclick or trough the menu. Now i want to make my qlikview document a lot more userfriendly. And this is liek this not/les the case. Because my table has always different results and different width's for the cell's text this "Fit Columns to Data" need to be pressed a lot.

snap.jpg

Is there a way that this is automated? Trough a function from qlikview itself or a macro?

If this aint possible... can this be done by adding a button to do this?

Iv'e read a lot topics about this, but they all dont do the ting asked.

7 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     You can use the functionality available under layout Tab "Size to Data"

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

This does not seem to work, at least not when it has been resized once. even when i uncheck it, save, check it and save again. mayby it need to be changed to "Always Size to Data"

marcus_sommer

It seems there is none method for doing this directly. But you could set the column width static with a fix value or by reference to any value - see for such examples APIGuide.qvw.

dim w(3)

w(1)=100

w(2)=150

w(3)=200

set chart = ActiveDocument.Sheets("Main").CreateStraightTable

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

chart.AddExpression "count(Product)"

chart.SetPixWidths 0,w

chart.EqualPixWidths 1

Brute force is to read every cell-value for each column and count the char to receive the max-value and set herewith the column width (not really recommended but possible).

- Marcus

Not applicable
Author

I have a pivot table, the script:

chart.SetPixWidths 0,w

chart.EqualPixWidths 1

doesn't work

Thanks

marcus_sommer

SetPixWidths is for straight tables and SetPixWidth without "s" for pivot tables.

- Marcus

Not applicable
Author

Yes! It's ok!

Thank you very much Marcus

AkbarShaikh
Contributor III
Contributor III

Hi Marcus,

I have a slightly different problem.. I am storing a QVD into an excel file and the width of one column is not adjusting to its longest data string. This is causing incorrect output in the excel file. 

Is there a way around this?

Regards,

a