XL.Sheet.SetColumn
------------------

Sets column width and format for all columns from colFirst to colLast.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XL](component_XL.md) | [3.5](newinversion35.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XL.Sheet.SetColumn"; BookRef; SheetIndex; ColFirst; ColLast; Width { ; Format; Hidden } ) 

**MBS**( **"XL.Sheet.SetColumn";** /\* Sets column width and format for all columns from colFirst to colLast. \*/  
**$BookRef**; /\* The reference number for the workbook.e.g. $ref \*/   
**$SheetIndex**; /\* The index of the sheet. This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-1.e.g. 0 \*/   
**$ColFirst**; /\* The first column. First column has index 0.e.g. $column \*/   
**$ColLast**; /\* The last column.e.g. $column \*/   
**$Width**; /\* The width of the column.  
Value -1 is used for autofit column widths.e.g. 5 \*/   
**$Format**; /\* Optional; The format index to use.  
You can use [XL.Book.AddFormat](XLBookAddFormat.md) to create new formats. \*/   
**$Hidden**) /\* Optional; Whether to hide column. Default is 0.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| BookRef | The reference number for the workbook. | $ref |  |
| SheetIndex | The index of the sheet. This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-1. | 0 |  |
| ColFirst | The first column. First column has index 0. | $column |  |
| ColLast | The last column. | $column |  |
| Width | The width of the column.   Value -1 is used for autofit column widths. | 5 |  |
| Format | The format index to use.   You can use [XL.Book.AddFormat](XLBookAddFormat.md) to create new formats. | $format | Optional |
| Hidden | Whether to hide column. Default is 0. | 0 | Optional |

### Result

Returns OK or error.

### Description

Sets column width and format for all columns from colFirst to colLast.   
Column width measured as the number of characters of the maximum digit width of the numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. Columns may be hidden.   
### See also

- [XL.Book.SheetCount](XLBookSheetCount.md)
- [XL.Format.SetNumFormat](XLFormatSetNumFormat.md)
- [XL.Sheet.SetBorder](XLSheetSetBorder.md)
- [XL.Sheet.SetCellFormat](XLSheetSetCellFormat.md)
- [XL.Sheet.SetCol](XLSheetSetCol.md)
- [XL.Sheet.SetColHidden](XLSheetSetColHidden.md)
- [XL.Sheet.SetColPx](XLSheetSetColPx.md)
- [XL.Sheet.SetFooter](XLSheetSetFooter.md)
- [XL.Sheet.SetRowPx](XLSheetSetRowPx.md)
- [XL.Sheet.SetZoom](XLSheetSetZoom.md)

### Release notes

- **Version 13.0**
    - Fixed [XL.Sheet.SetColumn](https://www.mbsplugins.eu/XLSheetSetColumn.shtml) and [XL.Sheet.SetRow](https://www.mbsplugins.eu/XLSheetSetRow.shtml) to better.

### Blog Entries

- [MBS FileMaker Plugin, version 12.6pr1](https://www.mbsplugins.de/archive/2022-12-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 26th July 2019

  
[XL.Sheet.SetColPx](XLSheetSetColPx.md) - [XL.Sheet.SetDefaultRowHeight](XLSheetSetDefaultRowHeight.md)

[HTML Version](XLSheetSetColumn.shtml)