Set Row Height in Excel Workbook in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source

The sample demonstrates how to set row height in Excel workbook via Spire.XLS.

using Spire.Xls;

namespace SetRowHeight
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"..\..\..\..\Data\parts.xls");
            Worksheet sheet = workbook.Worksheets[0];
            
            //set the RowHeight=25 of the first row
            sheet.SetRowHeight(1, 25);

            workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003);
            System.Diagnostics.Process.Start(workbook.FileName);
        }
    }
}

Imports Spire.Xls

Namespace SetRowHeight
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			Dim workbook As New Workbook()
			workbook.LoadFromFile("..\..\..\..\Data\parts.xls")
			Dim sheet As Worksheet = workbook.Worksheets(0)

			'set the RowHeight=25 of the first row
			sheet.SetRowHeight(1, 25)

			workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003)
			System.Diagnostics.Process.Start(workbook.FileName)
		End Sub
	End Class
End Namespace