使用excel列中的年份进行过滤时出现问题。
我使用C#编程语言,我不明白如何解决它,是否有人可以帮助我或提供一些关于如何在excel过滤器中找到年份的建议。
例如,如果我输入' 12/30/2016',它会成功搜索,但我想按年搜索(例如' 2016')。
以下是我的代码,任何建议表示赞赏。
Excel.Range range = WorksheetSource.UsedRange;
//tried by array format but i'm failing here at creteria2 value
range.AutoFilter(29, tByear.Text, XlAutoFilterOperator.xlFilterValues,test4[0,0], true);
//here i'm using xlor operator and textbox value will be like "2016"
range.AutoFilter(29, tByear.Text, Excel.XlAutoFilterOperator.xlOr, tByear.Text+ "*", true);
是否仅适用于完全匹配或任何其他答案,欢迎所有帮助。
答案 0 :(得分:0)
试试这个
Excel.Range currentFind = null;
xlworkSheet.Cells.Find(date,Type.Missing,Microsoft.Office.Interop.Excel.XlFindLookIn.xlValues,Microsoft.Office.Interop.Excel.XlLookAt.xlWhole,Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows,Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, false,Type.Missing, Type.Missing)