在Excel中查找字符串 [英] Find a string in excel
问题描述
我需要上传一个excel文件,它可以是任何格式.我需要先在Excel中找到一个字符串,然后才能在网格视图中显示值.
例如:
在一个excel中,前5行具有值,从第6行开始,我将具有填充gridview的数据.
在另一个excel中,前8行有一些值,从第10行开始,我将有数据填充gridview.
我的问题是如何从Excel中查找字符串或值,然后在网格视图中加载相应的值.
I need to upload an excel file and it''ll be any format. I need to find a string in that excel before showing the values in grid view.
For eg:
In one excel, first 5 rows have values and from 6th row onwards, I''ll have datas to fill the gridview.
In another excel, first 8 rows have some values and from 10 th row onwards, I''ll have datas to fill the gridview.
My question is how to find the string or value from that excel and then load that corresponding value in the grid view.
推荐答案
您可以使用 ^ ]用于在其中查找特定信息一个范围,并返回一个Range对象,该对象表示找到该信息的第一个单元格.
You can use Range.Find Method [^] which is used to finds specific information in a range and returns a Range object that represents the first cell where that information is found.
currentFind = this.Fruits.Find("YourSearchString", missing,
Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart,
Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false,
missing, missing);
参考链接:-在工作表范围内搜索文本 [ ^ ]
Reference Link :- Search for Text in Worksheet Ranges[^]
这篇关于在Excel中查找字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!