Filters and Column Unhiding

Hello,

I am having the following issues:

1) I edit a file (it can have multiple worksheets) and after the file is saved, when I load it with Excel, Filters are ON. I always have to go and turn it OFF. What is the correct way to just save a file and not have the autofilters on?

2) The original file contains several hidden columns and I want to Unhide them using Aspose Cells. I have tried to use the Unhide() method but the file remains the same. Can you please provide the correct usage to accomplish this?

I use C# on ASP.NET

Thanks in advance!

Hi,



Thanks for your post.


  1. For removing filters, the RemoveFilter Overloads method may serve the purpose.
    2) For Hiding / Unhiding of Rows / Columns, please visit this documentation link from Aspose.Cells for .NET online documentation.

    If the problem persists, please provide us the source template for further investigation.

    Kind Regards

Thank you for your reply.

Unhiding columns works fine. However, RemoveFilter, does not work. This is how I am implementing it:

// Remove filters and unhide columns.
for (int o = 0; o <= 132; o++)
{
workSheet.AutoFilter.RemoveFilter(o); // <— No effect at all.

if (o > 10)
{
workSheet.Cells.UnhideColumn(o, 3.71); // <— Works fine!
}
}

Is there a way to remove filters to the entire worksheet as a whole or do I have to always loop through the columns?

Hi,

We will get back to you soon.

Thank you.

Hi Manuel,

Please set the AutoFilter range as null to remove the autofilter. Following code snippet will help you.


Workbook workbook = new Workbook(@"F:\FileTemp\Book1.xls");
workbook.Worksheets[0].AutoFilter.Range = null;
workbook.Save(@"F:\FileTemp\dest.xls");

Thanks,

Sorry but this does not work.

This is what I have:

// Remove AutoFilters.
foreach (Worksheet wsheet in workbook.Worksheets)
{
wsheet.AutoFilter.Range = null;
}

// Save the completed spreadsheet.
workbook.Save(sFileProcessedLocation);

Am I doing something wrong?

Hi Manuel,

Firstly, the code provided to you previously and the code snippet which you are using should work. We need your Excel file which contains conditional formatting in order to further investigate the issue. Please share the Excel file with us.

Thanks,

Thanks for your quick response. I realized I was using Aspose.Cells version 4.8.2.6. So I downloaded version 5.1.2.5 and it now works.

Is 5.1.2.5 the latest version?

Hi Manuel,

Please find the updated version Aspose.Cells5.1.2.9.zip attached. Version v5.1.2.9 is the lastest version of Aspose.Cells.

Thanks,