+ Reply to Thread
Results 1 to 3 of 3

AutoFilter Data

Hybrid View

  1. #1
    AdamPinoy
    Guest

    AutoFilter Data

    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


  2. #2
    AdamPinoy
    Guest

    Re: 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 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



  3. #3
    AdamPinoy
    Guest

    Re: AutoFilter Data

    Hi,

    Does anyone has a solution or work around with this problem? 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 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



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1