AutoFilter Data
Hi,
Does anyone has anyone has a solution for this? Please help.
Regards.
AdamPinoy wrote:
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 procedu
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,Mi ssing.Value,Missing.Value,Missing.Value,Missing.Va lue,Missing.Value,Missing.Value,Missing.Value,Miss ing.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.XlAutoFilte rOperator.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.X lCellType.xlCellTypeVisible,Missing.Value);
Console.WriteLine(xRange.Rows.Count.ToString()); // but the counting
returns only 1 :(
Please help me with this endeavor. :(
Regards,
AdamPinoy
|