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

Free Support Forum - aspose.com

Removing AutoFilter from worksheet not working


I am trying to remove the autofilter on my worksheet with
worksheet.AutoFilter.Range = “”;

but when I save the worksheet to a pdf, it is only outputting the filtered rows. Can you help?

Attached is worksheet, code, expected and actual outputs.
AutoFilterRemoval.zip (33.1 KB)


You may please give a try to the following sample code and provide your feedback.

var workbook = new Workbook(@"AutoFilterRemoval\AutoFilter.xlsx");
var outputPath = @"AutoFilterRemoval\output.pdf";
foreach (var worksheet in workbook.Worksheets)
    worksheet.Cells.UnhideRows(0, worksheet.Cells.Rows.Count, -1);
var saveOptions = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
workbook.Save(outputPath, saveOptions);
1 Like


Quick follow up question. I was working with support on using worksheet.Cells.Columns.Count and I was having issues and in a similar case they had me use worksheet.Cells.MaxColumns +1. Would it be safer to use worksheet.Cells.MaxRow + 1 in this case?

Here is a reference to that question

Yes, you can use it as in your case it is returning correct value.