Set-Column-Width
Command Description
Set cell column width
Command Prototype
Excel.SetColumnWidth(objExcelWorkBook,sheet,strCell,fWidth,bSave)
Parameter Description
| Parameter | Required | Type | Default | Description | 
|---|---|---|---|---|
| objExcelWorkBook | True | expression | objExcelWorkBook | Excel workbook object (workbook opened with "Open Excel" command (Excel.OpenExcel) or the workbook object returned by the command "Bind Excel" (Excel.BindBook)) | 
| sheet | True | string | "Sheet1" | The string means sheet name. The number means sheet order(starting from 0) | 
| strCell | True | string | "A1" | Two forms of cell are supported: cell names (such as "A1") or array of rows and columns (such as [row number, column number]). It is case-insensitive to use cell names | 
| fWidth | True | number | 8.38 | The column width will be automatically adjusted between 0 and 255 pounds | 
| bSave | True | boolean | None | Save immediately after the operation | 
Demo
/************************Set column width************************ ********* 
**Input 1: 
**      objExcelWorkBook--Excel workbook object (a workbook opened using the  "Open Excel" command (Excel.OpenExcel)  or a job bound using the "Bind Excel" command (Excel.BindBook) book object). 
**Entry 2: 
**      sheet--If a string is used, it means the name of the specified worksheet; if a number is used, it means the order of the specified worksheet (starting from 0). 
**Entry 3: 
**      strCell--Specified cell, supports two forms of cell name such as "A1" and row and column array such as [row number, column number]. When using the cell name, it is not case-sensitive. 
**Entry 4: 
**      fWidth--Adjusted column width, between 0~255, when filling in other values, it will be automatically adjusted. 
**Entry 5: 
**      bSave--The operation is completed and saved immediately. (boolean true/false) 
** 
*********************************************************************/ 
  
objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","") 
Excel.SetColumnWidth(objExcelWorkBook,"Sheet1","A1",10,False) 
TracePrint "Set the column width: Set the column width to 10 for the column where the Excel object Sheet1'A1' is located" 
Excel.CloseExcel(objExcelWorkBook,True)