Home > Back-end >  C# Excel VSTO save a Filter in Sheet View
C# Excel VSTO save a Filter in Sheet View

Time:08-13

It´s possible to save a filter in Excel using COM API? This feature is very useful if you have someone else working with the same excel to have a different filter for each user.

enter image description here

I know there is a new Interfaces to do this job:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.sheetviews?view=excel-pia

CodePudding user response:

You need to enumerate the SheetViews collection that is a member of Application.ActiveWindow.

Application app = /*your_Excel_app*/;

var activeWindow = app.ActiveWindow;

foreach (WorksheetView view in activeWindow.SheetViews)
{
    // do something
}
  • Related