XLSetColWidth(xlHandle As Integer, optional formatHandle As Integer, firstColum As Integer, lastColumn As Integer, width As Double)

 

Sets the column width.

 

xlHandle to an Excel file is obtained by the XLCreateFromTemplate function. The column width is applied to columns of the first sheet of the Excel file. formatHandle is an optional parameter which can be omitted. A formatHandle can be obtained by a call to XLAddFormat.htm.

 

 

Parameters:

 

Name

Type

Value

Description

xlHandle

Integer

0 - n

A handle to an Excel document. The document must have been created by using the function XLCreateFromTemplate and the Integer we obtained from it is used as xlHandle here.

formatHandle

Integer

0 - n

Optional handle to a format object. The formatHandle is is obtained by a call to XLAddFormat

firstColum

Integer

0 – n

Index of first column to set width

lastColumn

Integer

0 – n

Index of last column to set width

width

Double

0 – n

Width of a column, as a double value.

Example: 10.85

A value of -1 sets the column to AutoFit

 

Available in:

 

WindowMain

WindowLink

YES

NO

 

Used in:

 

XojoScript Name

GUID

Save as Excel sheet : seminar invoice list

6DDAFA87-2862-4129-8416-CBD57C5CDF9A

Save as Excel sheet : seminar participants list

03C22A3D-FF28-4E22-BB99-D7626BF5F0A4

Save As Excel sheet : participants list

E50602AA-F1F7-42E6-A44A-78456DD9B778

 

Hint: You can find more references to XojoScripts which make use of this function by sending the following SQL statement to the database: Select id,GUID, ScriptName,ScriptCode from im_scripts where ScriptCode Like '%XLSetColWidth%'

 

Example XojoScript:

 

Dim hXL As Integer

 

// Get Handle to newly created Excel file

hXL = XLCreateFromTemplate("myXLtest.xls")

 

If hXL > -1 Then

Dim i As integer

For i = 2 To 100

XLWriteString(hXL,i,0,"Zeile " + Str(i))

XLWriteNumber(hXL,i,1,i)

XLWriteBoolean(hXL,i,2,i)

Next

 

// Set Column Widths, -1 = AutoFit

Dim w As Double = 10

XLSetColWidth(hXL,0,0,w) 

XLSetColWidth(hXL,1,2,-1// AutoFit

 

XLSave(hXL)

XL(hXL,"launch")

 

End If