Page 1 of 1

AutoWidthCols code example

PostPosted: Thu Feb 23, 2017 6:16 am
by MaxChan
Dear Support,

I try to set the col width to auto. But it never works. Do you have any example code for "AutoWidthCols";

My code:
First column - fix width to 200.
XSS.XLS[0].Columns[0].CharWidth := 20;
XSS.XLS[0].Columns[0].PixelWidth := 200;
The other column - autowidth.


Any problem on my code?

Re: AutoWidthCols code example

PostPosted: Fri Feb 24, 2017 8:15 am
by larsa

I can't see any problem with your code but you don't have to use both CharWidth and PixelWidth. Only the last will be used. You shall avoid to use PixelWidth as the result will not be as expected on high resolution monitors (dpi other than 96).

Re: AutoWidthCols code example

PostPosted: Fri Feb 24, 2017 11:18 am
by MaxChan
Dear Larsa,

Still not work, event I just pull XSS.XLS[0].AutoWidthCols(0,100);

Is there anyway that I can set the width of all column.
I tried
XSS.XLS[0].Columns[0].CharWidth := 200;
XSS.XLS[0].Columns[0].PixelWidth := 200;

The width of column no have effect.
Also, tried

Re: AutoWidthCols code example

PostPosted: Tue Feb 28, 2017 3:04 pm
by larsa

The problem is that the spreadsheet not is redrawn when you call InvalidateSheet. You can force a redraw by resizing the form with the sheet. Will fix this in the next update.