Click or drag to resize

IWorksheet GetColumnWidthPixels Method

Returns width in pixels from ColumnInfoRecord if there is corresponding ColumnInfoRecord or StandardWidth if not.
Examples
The following code illustrates how to get the column width for a particular column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Sample text in cell";</para><para>//Set auto fit</para><para>worksheet.AutoFitColumn(1);</para><para>//Get column width</para><para>Console.WriteLine(worksheet.GetColumnWidthPixels(1));</para><para>//Save to file</para><para>workbook.SaveToFile("UsedRange.xlsx");</para>

Namespace: Spire.Xls.Core
Assembly: Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
int GetColumnWidthPixels(
	int Column
)

Parameters

Column
Type: System Int32
One-based index of the column.

Return Value

Type: Int32
Width in pixels of the specified column.
See Also