Excel c#.net在不在后台打开Excel的情况下检索数据 [英] Excel c#.net retrieving data without opening excel in the background

查看:72
本文介绍了Excel c#.net在不在后台打开Excel的情况下检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我试图从Excel电子表格中读取数据而无需声明:



Excel.Application等



有没有办法通过ADO.Net或以某种方式使用ODBC来检索数据?



例如找到一定值,范围,工作表?



谢谢,





Jase

解决方案

当然。这样的东西就是你要找的东西,我相信:



http://stackoverflow.com/questions/15828/reading-excel-files-from-c-sharp [ ^ ]


这里是如何使用ODBC和ADO.Net做它



 私有  void  Form1_Load( object  sender,EventArgs e)
{
尝试
{
字符串 sheetName = < span class =code-string> Sheet1


; // 阅读整个Excel工作表文件
DataTable sheetTable = loadSingleSheet( @ C:\ excelFile.xls,sheetName);
dataGridView1.DataSource = sheetTable;

string sheetNameWithRange = Sheet 1中

Hi,

I am trying to read data from an Excel spreadsheet without having to declare:

Excel.Application, etc

Is there a way via ADO.Net or somehow using ODBC to retrieve the data ?

e.g find a certain value, range, worksheet ?

Thanks,


Jase

解决方案

Sure. Something like this is what you are looking for, I believe:

http://stackoverflow.com/questions/15828/reading-excel-files-from-c-sharp[^]


Here it is how to do it using ODBC and ADO.Net

private void Form1_Load(object sender, EventArgs e)
{   
   try
   {        
        string sheetName = "Sheet1


";// Read the whole excel sheet document DataTable sheetTable = loadSingleSheet(@"C:\excelFile.xls", sheetName); dataGridView1.DataSource = sheetTable; string sheetNameWithRange = "Sheet1


这篇关于Excel c#.net在不在后台打开Excel的情况下检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆