Display or Hide Row Column Headers in Aspose.Cells

Controlling the Visibility of the Worksheets

Aspose.Cells provides a class, Workbook, that represents a Microsoft Excel file. The Workbook class contains a Worksheets collection that allows access to each worksheet in an Excel file.

A worksheet is represented by the Worksheet class. The Worksheet class provides a wide range of properties and methods for managing worksheets. To control the visibility of row and column headers, use the Worksheet class' IsRowColumnHeadersVisible property. IsRowColumnHeadersVisible is a Boolean property, which means that it can only store a true or false value.

A complete example is given below that shows how to use the Worksheet class' IsRowColumnHeadersVisible property to hide row and column headers on the first worksheet in a file.

The screenshot shows Book1.xls, the input file. It contains three worksheets: Sheet1, Sheet2 and Sheet3. Each worksheet is showing row and column headers.

Book1.xls: worksheet before modification


Book1.xls is opened by calling the Workbook class' Open method and the row and column headers on the first worksheet are hidden. The modified file is saved as output.xls.

Output.xls: worksheet after modification



 //Creating a file stream containing the Excel file to be opened

FileStream fstream = new FileStream("book1.xls", FileMode.Open);

//Instantiating a Workbook object

//Opening the Excel file through the file stream

Workbook workbook = new Workbook(fstream);

//Accessing the first worksheet in the Excel file

Worksheet worksheet = workbook.Worksheets[0];

//Hiding the headers of rows and columns

worksheet.IsRowColumnHeadersVisible = false;

//Saving the modified Excel file


//Closing the file stream to free all resources


Download Running Code

Download Sample Code