Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Excel Formatting via TCL

302 views
Skip to first unread message

Roy Terry

unread,
Jan 13, 2007, 2:43:59 PM1/13/07
to
"Wajih" <wajihur...@gmail.com> wrote in message
news:1168713901.2...@q2g2000cwa.googlegroups.com...
> Hello,
>
> I am using TCL/TCOM to write my data in the Excel sheet. However, I
> have problem in selection of background and text colour , Column width
> setting to autofit .
>
> Can anybody send me some examples?
>
> Wajih

Wajih,

First check
http://mini.net/tcl/Tcom%20examples%20for%20Microsoft%20Excel

I do have tcom-based code for Excel for at least some
of the cell properties like background. However the code
is not easily abstracted into an example. Can you
post the details of what you've tried and then perhaps
Myself and others can offer concrete suggestions.

>


Wajih

unread,
Jan 15, 2007, 3:50:49 AM1/15/07
to
Hello,

I did the following database:

# cell Properties for the first header line
set range [$worksheet Range J1 P1]

$application DisplayAlerts [expr 0]
set font [$range Font]
$font Bold [expr 1]

$range HorizontalAlignment $align(horiz,center)
$range VerticalAlignment $align(vert,center)

$range MergeCells [expr 1]
$application DisplayAlerts [expr 1]


# Define a range of cells to use with the following commands.
set range [$worksheet Range A2 P2]
set font [$range Font]
$font Bold [expr 1]
$range Orientation [expr 90]

after this , I added values in the column. However, the column width is
default and therefore , I want these columns to fit to the data size.

for this , I tried many things one is below:

#set beginrange A
#set endrange AN
#set range [$worksheet Range $beginrange $endrange]

This above command does not work. Probably we can not defined the
column range.

then I defined the range with cell like A3 AN3

and enter the following db

$application DisplayAlerts [expr 0]
$range AutoFit [expr 1]
$application DisplayAlerts [expr 1]

does not work also . It says AutoFit should be the argument which might
be correct as there is no TRUE/FALSE option. So I am stuck how to
defined AutoFit.


$application DisplayAlerts [expr 0]
$range ShrinkToFit [expr 1]
$application DisplayAlerts [expr 1]

But this did something else and fit the text in the cell.

So , I do not know have any idea how to adjust the column width to the
suitable size as per data .

Anyone can help?

Wajih

unread,
Jan 13, 2007, 1:45:03 PM1/13/07
to wajihur...@gmail.com

nje...@gmail.com

unread,
Oct 18, 2018, 3:00:24 PM10/18/18
to
I know this is 11 years too late, but I came across this post while trying to solve the same problem of using autofit on columns with Tcl/Tcom. Here is how I got it to work for anyone else trying to do this:

#define the range
set range [$worksheet Range "A:N"]

#get the columns in my range
set columns [$range Columns]

#use the autofit function on the selected columns
$columns AutoFit
0 new messages