We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

XlsIO: Problem updating an existing AutoFilter.FilterRange in a worksheet ListObject

So I'm having an issue with the worksheets existing AutoFilter not updating its FilterRange after I import data using worksheet.ImportDataTable.

In my use case, I have the worksheet that has an existing table that comes in as a worksheet.ListObject with an already defined AutoFilter.FilterRange set to worksheet.Range["B8:O9"];

I use worksheet.ImportDataTable(table, false, range.Row, range.Column, false); and the data is imported correctly. However, the AutoFilter.FilterRange is not updated to the new LastRow.

I've tried updating the range by using worksheet.ListObjects[0].AutoFilter.FilterRange = worksheet.Range["B8:O10"]; 
But the FilterRange doesn't update. I also noticed that the worksheet.ListObjects[0].Location was not updated to the last row of data either.

There's no AutoFilter on the worksheet object either. It seems to be isolated to just the ListObject table.

Is there any way around this? Should I remove the AutoFilter from the ListObject and move it to the worksheet object?

2 Replies

PD Peter deNoyelles September 5, 2019 06:41 PM UTC

Answering my own question as I found a solution.

To update the AutoFilter.FilterRange of a ListObject, I had to update the ListObject.Location. This then automatically updated the AutoFilter.FilterRange of the ListObject.

AV Abirami Varadharajan Syncfusion Team September 6, 2019 01:52 PM UTC

Hi Peter, 

Greetings from Syncfusion. 

As like you mentioned, updating the table range will update the filter range of the table.  

Please let us know if you need further assistance. 


Live Chat Icon For mobile
Up arrow icon