我如何从Excel文件中读取数据以及检查后需要在数据网格或网格视图中显示 [英] How can i read data from excel file and after check need to display in data grid or grid view
本文介绍了我如何从Excel文件中读取数据以及检查后需要在数据网格或网格视图中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名称为ABC的Excel文件
excel文件中有4列
现在我要检查colA是否具有id 3,然后复制该数据并在Grid View中显示
我该如何执行此任务
我想使用dev express的上传控件
并且每次文件可能都不同
我该如何执行呢?
请帮助我
抱歉我的英语不好
I have an Excel file with name ABC
there are 4 column in the excel file
now i want to check that if colA have id 3 then copy that data and show in the Grid View
How can i perform this task
and i want to use upload control of dev express
and every time the file may be different
how can i perform this?
please help me
and sorry for my bad english
推荐答案
我的语法可能已关闭,但是我以前用excel编程,所以它足够接近,您可以用谷歌的真实方式来搜索.
使用openfile对话框允许不同的文件名.您还可以在此对话框中放置一个过滤器,以仅允许使用excel文档.
确保附上Microsoft.Interop.Excel(您需要的任何版本)
然后在您的表单中执行以下操作:
My syntax may be off but I used to program with excel so it''ll be close enough for you to google the true way.
Use the openfiledialog to allow different file names. You can also put a filter in this dialog to only allow excel documentation.
Make sure to attach Microsoft.Interop.Excel(whichever version you need)
then inside your form do something along the lines:
#import interop.excel
public class myClass
private sub LoadFile
if openfiledialog.ok
dim newExcelFile as file = openfiledialog.path
newexcelfile.open
while newexcelfile.rows(idx).cells(0) is not nothing
if newexcelfile.rows(idx).cells(0) = 3
addtomyDataGrid(newexcelfile.rows(idx))
endif
idx += 1
end while
end if
end sub
end class
这篇关于我如何从Excel文件中读取数据以及检查后需要在数据网格或网格视图中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文