如何从第一个单元格(包括其自身)开始在Excel中搜索. [英] How to search in Excel starting from first cell including itself.
问题描述
你好,
由于我是C#编程的新手,因此遇到了这个问题.
我需要打开一个XL文件,找到包含特定字符串的单元格.
但是我面临的问题是,在不同的单元格中有多个相同字符串的实例.
例如:如果单元格[1,1]具有测试",而单元格[12,5]也具有测试",那么我在[12,5]处获得了返回值,但我想要[1,1],请问任何一个帮助我确定如何从[1,1]开始搜索,其中包括单元格[1,1].
以下是代码段.
Hello,
As i am new to C# programming i came across this problem.
I need to open an XL file find the cell which contains a particluar string.
But the problem i face is when there are more than one instances of the same string in different cells.
Eg: if cell [1,1] has "test" and cell [12,5] also has "test" then i get the returned value at [12,5] but i want [1,1], can any one please help me out how i can start searching from [1,1] which includes the cell [1,1].
Following is the snippet.
Excel.Application XLFile = new Excel.Application();
Excel.Workbook XLworkbook;
Excel.Worksheet XLSheet;
XLworkbook = XLFile.Workbooks.Open(@"C:\temp.xls",
2,
true,
5,
"",
"",
true,
Excel.XlPlatform.xlWindows,
0,
false,
false,
false,
false,
true,
Excel.XlCorruptLoad.xlNormalLoad);
XLSheet = (Excel.Worksheet)XLFile.ActiveSheet;
Excel.Range FindCell;
object Missing = System.Reflection.Missing.Value;
FindCell = XLSheet.Cells.Find("test", issing, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByColumns, Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, true, false, false);
推荐答案
您是否看过 ^ ]?
这可能会有所帮助. :)
Have you looked at this[^]?
It may help. :)
这篇关于如何从第一个单元格(包括其自身)开始在Excel中搜索.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!