AutoWidthCols code example

Questions and answers on how to use XLSSpreadSheet.
Post Reply
MaxChan
Posts: 19
Joined: Sat Sep 03, 2016 6:38 am

AutoWidthCols code example

Post 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.
XSS.XLS[0].AutoWidthCols(1,100);

XSS.Invalidatesheet;

Any problem on my code?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: AutoWidthCols code example

Post by larsa »

Hello

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).
Lars Arvidsson, Axolot Data
MaxChan
Posts: 19
Joined: Sat Sep 03, 2016 6:38 am

Re: AutoWidthCols code example

Post 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
xss.Repaint;
XSS.InvalidateSheet;
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: AutoWidthCols code example

Post by larsa »

Hello

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.
Lars Arvidsson, Axolot Data
Post Reply