Hi,
I have a C# code that use an excel appliction. In my code, I use the
AutoFilter in a certain range. My question is how could I get the
return values of the autofilter and manipulate/scan the return data.
Below is my code taken in a certain procedure:
m_ExcelApp = new Excel.ApplicationClass();
m_ExcelApp.Visible = true; // make it visible
Excel.Workbook wbActiveBook =
m_ExcelApp.Workbooks.Open("d:\Sample.xls",Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);
Excel.Worksheet wsActiveSheet =
(Excel.Worksheet)wbActiveBook.Worksheets[1];
Excel.Range rYearRange = wsActiveSheet.get_Range("A1","Z784");
// Applying Filter on Column 11 where value is 2001
rYearRange.AutoFilter(11,"=2001",Excel.XlAutoFilterOperator.xlAnd,Missing.Value,Missing.Value);
// In Excel Sheet, it returns 3.
// They said use the UsedRange but it doesn't return the desired
output.
Excel.Range retRange =
wsActiveSheet.UsedRange.Cells.SpecialCells(Excel.XlCellType.xlCellTypeVisible,Missing.Value);
Console.WriteLine(xRange.Rows.Count.ToString()); // but the counting
returns only 1
Please help me with this endeavor.
Regards,
AdamPinoy
Bookmarks