AutoWidthCols code example

Questions and answers on how to use XLSSpreadSheet.

AutoWidthCols code example

Postby MaxChan » Thu Feb 23, 2017 6:16 am

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?
MaxChan
 
Posts: 12
Joined: Sat Sep 03, 2016 6:38 am

Re: AutoWidthCols code example

Postby larsa » Fri Feb 24, 2017 8:15 am

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
larsa
Site Admin
 
Posts: 574
Joined: Mon Jun 27, 2005 9:30 pm

Re: AutoWidthCols code example

Postby MaxChan » Fri Feb 24, 2017 11:18 am

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;
MaxChan
 
Posts: 12
Joined: Sat Sep 03, 2016 6:38 am

Re: AutoWidthCols code example

Postby larsa » Tue Feb 28, 2017 3:04 pm

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
larsa
Site Admin
 
Posts: 574
Joined: Mon Jun 27, 2005 9:30 pm


Return to XLSSpreadSheet

Who is online

Users browsing this forum: No registered users and 1 guest

cron