How to Freeze Top Row and Apply Filter in Excel Automation with C

0 votes
I have automated Excel document creation using C#. I'm attempting to apply a filter while also freezing the worksheet's top row. If you choose View > Freeze Panes > Freeze top row, followed by top row Data > Filter, this is the same as in Excel 2010. I have no idea how to use the filter, but I tried the following to freeze the top row, and it simply frozen the entire worksheet. I'm looking for a solution to my issue. I need additional assistance with the data filter issue; if you know of a solution, kindly let me know.
Oct 21 in Others by Kithuzzz
• 20,660 points
85 views

1 answer to this question.

0 votes

Try this:

// Fix first row
workSheet.Activate();
workSheet.Application.ActiveWindow.SplitRow = 1;
workSheet.Application.ActiveWindow.FreezePanes = true;
// Now apply autofilter
Excel.Range firstRow = (Excel.Range)workSheet.Rows[1];
firstRow.AutoFilter(1, 
                    Type.Missing, 
                    Excel.XlAutoFilterOperator.xlAnd, 
                    Type.Missing, 
                    true);
answered Oct 22 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
0 answers
0 votes
1 answer

How do I get an Excel range using row and column numbers in VSTO / C#?

Use: int countRows = xlWorkSheetData.UsedRange.Rows.Count; int countColumns = xlWorkSheetData.UsedRange.Columns.Count; object[,] ...READ MORE

answered Nov 17 in Others by narikkadan
• 37,660 points
25 views
0 votes
1 answer

How to insert a new row in the specified cell only, of Excel sheet using c#?

I have this worksheet with a matrix ...READ MORE

answered 3 days ago in Others by narikkadan
• 37,660 points
8 views
0 votes
1 answer

Generate a flat list of all excel cell formulas

Hello, you'll have to follow certain steps ...READ MORE

answered Feb 18 in Others by gaurav
• 22,040 points
73 views
0 votes
0 answers

Format an Excel column (or cell) as Text in C#?

When I copy values from a data ...READ MORE

Oct 31 in Others by Kithuzzz
• 20,660 points
43 views
0 votes
1 answer

Microsoft.Office.Interop.Excel for Office 2007

Each client must install the  2007 Microsoft ...READ MORE

answered Nov 5 in Others by narikkadan
• 37,660 points
41 views
0 votes
1 answer

Obtaining Excel worksheet reference by worksheet name via C#

Instead of using Excel.Workbook.Sheets collection, it's easier to access Excel.Workbook.Worksheet collection, ...READ MORE

answered Nov 10 in Others by narikkadan
• 37,660 points
22 views
0 votes
1 answer

How to freeze the top row and the first column using XlsxWriter?

You can use worksheet.freeze_panes() to achieve this . There ...READ MORE

answered Oct 11 in Others by narikkadan
• 37,660 points
146 views
0 votes
1 answer

How to use data validation and 'no filter' in excel

eventually succeeded in resolving this. Effectively, Filter() ...READ MORE

answered Nov 4 in Others by narikkadan
• 37,660 points
35 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP