We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Hide column?

Is it possible to hide a column using Aspose.Excel? How would I go about doing it.

You can set the column width to 0 to hide it. For example,

cells.SetColumnWidth(1, 0); // hide column B


Hi,

I also want to hide colums but when I set the width to 0, my column is actually of width 0.42…
What should I do ?

Thanks,
Laurent.

Hi, Laurent.

What’s the version are you using? Please download fix 1.8.5 and have a try. If problem still exists, please post more of your code here. Thanks.

@Laurent,
We have introduced a new product Aspose.Cells which has replaced Aspose.Excel. This new product Aspose.Cells contains all the latest features available in MS Excel and is much better in terms of performance and stability. We can show and hide rows and columns using this new product as depicted in the following sample code:

Hiding rows and columns

// Instantiating a Workbook object
// Opening the Excel file through the file stream
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);
Workbook workbook = new Workbook(fstream);

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

// Hiding the 3rd row of the worksheet
worksheet.Cells.HideRow(2);

// Hiding the 2nd column of the worksheet
worksheet.Cells.HideColumn(1);

// Saving the modified Excel file
workbook.Save(dataDir + "output.out.xls");

// Closing the file stream to free all resources
fstream.Close();

Showing rows and columns

// Instantiating a Workbook object
// Opening the Excel file through the file stream
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);    
Workbook workbook = new Workbook(fstream);

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

// Unhiding the 3rd row and setting its height to 13.5
worksheet.Cells.UnhideRow(2, 13.5);

// Unhiding the 2nd column and setting its width to 8.5
worksheet.Cells.UnhideColumn(1, 8.5);

// Saving the modified Excel file
workbook.Save(dataDir + "output.xls");

// Closing the file stream to free all resources
fstream.Close();

A detailed article about hiding and showing rows and columns is given below:
Hiding and Showing Rows and Columns

Get the latest version of this new product here:
Aspose.Cells for .NET (Latest Version)

You may test a variety of product features by downloading the sample project here.