|
| 1 | +--- |
| 2 | +title: Unit of row height and column width in Excel | Syncfusion |
| 3 | +description: This page explains about the default unit of measurement for row height and column width in Excel using Syncfusion .NET Excel library (XlsIO). |
| 4 | +platform: document-processing |
| 5 | +control: XlsIO |
| 6 | +documentation: UG |
| 7 | +--- |
| 8 | + |
| 9 | +# What is the unit of row height and column width in Excel? |
| 10 | + |
| 11 | +By default, XlsIO uses **points** as the unit of measurement for both row height and column width. |
| 12 | + |
| 13 | +Use <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_SetColumnWidth_System_Int32_System_Double_">SetColumnWidth</a> |
| 14 | + and <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_SetRowHeight_System_Int32_System_Double_">SetRowHeight</a> to set dimensions in points. |
| 15 | + |
| 16 | +Use <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_GetColumnWidth_System_Int32_">GetColumnWidth</a> and <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_GetRowHeight_System_Int32_">GetRowHeight</a> to retrieve dimensions in points. |
| 17 | + |
| 18 | +If you need pixel values, XlsIO provides pixel based APIs: <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_GetColumnWidthInPixels_System_Int32_">GetColumnWidthInPixels</a>, <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_GetRowHeightInPixels_System_Int32_">GetRowHeightInPixels</a>, <a href="https://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_SetColumnWidthInPixels_System_Int32_System_Int32_">SetColumnWidthInPixels</a>, <a href="http://help.syncfusion.com/cr/document-processing/Syncfusion.XlsIO.IWorksheet.html#Syncfusion_XlsIO_IWorksheet_SetRowHeightInPixels_System_Int32_System_Double_">SetRowHeightInPixels</a>. |
| 19 | + |
| 20 | +{% tabs %} |
| 21 | +{% highlight c# tabtitle="C# [Cross-platform]" %} |
| 22 | +//Set column width in points |
| 23 | +sheet.SetColumnWidth(1, 20); |
| 24 | + |
| 25 | +//Get column width in points |
| 26 | +var widthPoints = sheet.GetColumnWidth(1); |
| 27 | +Console.WriteLine("Column width in points: " + widthPoints); |
| 28 | + |
| 29 | +//Set column width in pixels |
| 30 | +sheet.SetColumnWidthInPixels(1, 160); |
| 31 | + |
| 32 | +//Get column width in pixels |
| 33 | +var widthPixels = sheet.GetColumnWidthInPixels(1); |
| 34 | +Console.WriteLine("Column width in pixels: " + widthPixels); |
| 35 | + |
| 36 | +//Set row height in points |
| 37 | +sheet.SetRowHeight(1, 15); |
| 38 | + |
| 39 | +//Get row height in points |
| 40 | +var heightPoints = sheet.GetRowHeight(1); |
| 41 | +Console.WriteLine("Row height in points: " + heightPoints); |
| 42 | + |
| 43 | +//Set row height in pixels |
| 44 | +sheet.SetRowHeightInPixels(1, 40); |
| 45 | + |
| 46 | +//Get row height in pixels |
| 47 | +var heightPixels = sheet.GetRowHeightInPixels(1); |
| 48 | +Console.WriteLine("Row height in pixels: " + heightPixels); |
| 49 | +{% endhighlight %} |
| 50 | + |
| 51 | +{% highlight c# tabtitle="C# [Windows-specific]" %} |
| 52 | +//Set column width in points |
| 53 | +sheet.SetColumnWidth(1, 20); |
| 54 | + |
| 55 | +//Get column width in points |
| 56 | +var widthPoints = sheet.GetColumnWidth(1); |
| 57 | +Console.WriteLine("Column width in points: " + widthPoints); |
| 58 | + |
| 59 | +//Set column width in pixels |
| 60 | +sheet.SetColumnWidthInPixels(1, 160); |
| 61 | + |
| 62 | +//Get column width in pixels |
| 63 | +var widthPixels = sheet.GetColumnWidthInPixels(1); |
| 64 | +Console.WriteLine("Column width in pixels: " + widthPixels); |
| 65 | + |
| 66 | +//Set row height in points |
| 67 | +sheet.SetRowHeight(1, 15); |
| 68 | + |
| 69 | +//Get row height in points |
| 70 | +var heightPoints = sheet.GetRowHeight(1); |
| 71 | +Console.WriteLine("Row height in points: " + heightPoints); |
| 72 | + |
| 73 | +//Set row height in pixels |
| 74 | +sheet.SetRowHeightInPixels(1, 40); |
| 75 | + |
| 76 | +//Get row height in pixels |
| 77 | +var heightPixels = sheet.GetRowHeightInPixels(1); |
| 78 | +Console.WriteLine("Row height in pixels: " + heightPixels); |
| 79 | +{% endhighlight %} |
| 80 | + |
| 81 | +{% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} |
| 82 | +'Set column width in points |
| 83 | +sheet.SetColumnWidth(1, 20) |
| 84 | + |
| 85 | +'Get column width in points |
| 86 | +Dim widthPoints As Integer = sheet.GetColumnWidth(1) |
| 87 | +Console.WriteLine("Column width in points: " & widthPoints) |
| 88 | + |
| 89 | +'Set column width in pixels |
| 90 | +sheet.SetColumnWidthInPixels(1, 160) |
| 91 | + |
| 92 | +'Get column width in pixels |
| 93 | +Dim widthPixels As Integer = sheet.GetColumnWidthInPixels(1) |
| 94 | +Console.WriteLine("Column width in pixels: " & widthPixels) |
| 95 | + |
| 96 | +'Set row height in points |
| 97 | +sheet.SetRowHeight(1, 15) |
| 98 | + |
| 99 | +'Get row height in points |
| 100 | +Dim heightPoints As Integer = sheet.GetRowHeight(1) |
| 101 | +Console.WriteLine("Row height in points: " & heightPoints) |
| 102 | + |
| 103 | +'Set row height in pixels |
| 104 | +sheet.SetRowHeightInPixels(1, 40) |
| 105 | + |
| 106 | +'Get row height in pixels |
| 107 | +Dim heightPixels As Integer = sheet.GetRowHeightInPixels(1) |
| 108 | +Console.WriteLine("Row height in pixels: " & heightPixels) |
| 109 | +{% endhighlight %} |
| 110 | +{% endtabs %} |
0 commit comments