Syncfusion.XlsIO.Base
Example 


Syncfusion.XlsIO Namespace > IWorksheet Interface : GetColumnWidthInPixels Method
One-based column index.

GetColumnWidthInPixels Method

Returns the width of the specified column in pixels.
Syntax
'Declaration
 
Function GetColumnWidthInPixels( _
   ByVal iColumnIndex As Integer _
) As Integer
'Usage
 
Dim instance As IWorksheet
Dim iColumnIndex As Integer
Dim value As Integer
 
value = instance.GetColumnWidthInPixels(iColumnIndex)
int GetColumnWidthInPixels( 
   int iColumnIndex
)

Parameters

iColumnIndex
One-based column index.

Return Value

Width in pixels of the specified column.
Example
The following code illustrates how to get the column width for a particular column.
using Syncfusion.XlsIO;
using System;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Set text
            worksheet["A1"].Text = "Sample text in cell";
            
            //Set auto fit
            worksheet.AutofitColumn(1);
            
            //Get column width
            Console.WriteLine(worksheet.GetColumnWidthInPixels(1));
            
            //Save and dispose
            workbook.SaveAs("CellFormats.xlsx");
            workbook.Close();
            Console.ReadKey();
        }
    }
}
//Output will be
//129
AssemblyVersion

Syncfusion.XlsIO.Base: 16.3460.0.29

See Also