2017-02-10 67 views
0

我有一個問題,當在excel列中使用年份進行過濾。excel自動過濾器搜索年,不從C#工作#

我正在使用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

試試這個

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) 
+0

喜rishit,我的問題是,不僅要發現價值,但它應該過濾從列特殊的價值。我只是想根據用戶輸入過濾結果。 。 – CharanS