Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

NamedRange.ColumnWidth Property

Gets or sets the width of all columns in the NamedRange control.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public Object ColumnWidth { get; set; }

Property Value

If all columns in the NamedRange control have the same width, this property returns an object that represents the width. If columns in the range have different widths, this property returns a null reference (Nothing in Visual Basic).

One unit of column width is equal to the width of one character in the Normal style. For proportional fonts, the width of the character 0 (zero) is used.

Use the Width property to return the width of a column in points.

The following code example creates a NamedRange and then sets the width of the columns and the height of the rows that are part of the range.

Microsoft.Office.Tools.Excel.NamedRange setColumnRowRange;
private void SetColumnAndRowSizes()
    setColumnRowRange = this.Controls.AddNamedRange(
        this.Range["C3", "E6"], "setColumnRowRange");
    this.setColumnRowRange.ColumnWidth = 20;
    this.setColumnRowRange.RowHeight = 25;

© 2015 Microsoft