Hide Worksheet Row in Excel in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source

The sample demonstrates how to hide worksheet row in Excel workbook via Spire.XLS.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Spire.Xls;

namespace RowHide
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"..\..\..\..\Data\parts.xls");
            Worksheet sheet = workbook.Worksheets[0];

            //hide the fourth row of sheet
            sheet.HideRow(4);

            //hide the seventh row of sheet
            sheet.HideRow(7);

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

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Imports Spire.Xls

Namespace RowHide
	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)

			'hide the fourth row of sheet
			sheet.HideRow(4)

			'hide the seventh row of sheet
			sheet.HideRow(7)

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