Common way is:

var fileName = string.Format("{0}\\fileNameHere", Directory.GetCurrentDirectory());
var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName); var adapter = new OleDbDataAdapter("SELECT * FROM [workSheetNameHere$]", connectionString);
var ds = new DataSet(); adapter.Fill(ds, "anyNameHere"); DataTable data = ds.Tables["anyNameHere"];

see details at: http://stackoverflow.com/questions/15828/reading-excel-files-from-c-sharp

the connect string is:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;

Extended Properties="Excel 12.0 Xml;HDR=YES";

(HDR=YES: read the header)

see the connect strings of Excel: http://www.connectionstrings.com/excel-2007/

There is an error if your system is your system is 64bit:

Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

Change the application to 32bit to avoid this problem, see: http://stackoverflow.com/questions/238625/microsoft-ace-oledb-12-0-provider-is-not-registered

If using this code to read Excel file on Windows Azure, we can't change it to 32bit, so we need find another way:

http://stackoverflow.com/questions/3663245/read-excel-file-and-insert-records-in-database-in-c-windows-azure

that is:

For the time being you are basically restricted to .NET-only options:

EPPlus examples:

http://www.codeproject.com/Articles/680421/Create-Read-Edit-Advance-Excel-2007-2010-Report-in#1

http://blog.fryhard.com/archive/2010/10/28/reading-xlsx-files-using-c-and-epplus.aspx

NPOI source:

https://github.com/tonyqus/npoi

Read Excel file from C#的更多相关文章

  1. NetSuite SuiteScript 2.0 export data to Excel file(xls)

    In NetSuite SuiteScript, We usually do/implement export data to CSV, that's straight forward: Collec ...

  2. csharp:using OpenXml SDK 2.0 and ClosedXML read excel file

    https://openxmlexporttoexcel.codeplex.com/ http://referencesource.microsoft.com/ 引用: using System; u ...

  3. Creating Excel File in Oracle Forms

    Below is the example to create an excel file in Oracle Forms.Pass the Sql query string to the below ...

  4. Formatting Excel File Using Ole2 In Oracle Forms

    Below is the some useful commands of Ole2 to format excel file in Oracle Forms.-- Change font size a ...

  5. Read / Write Excel file in Java using Apache POI

    Read / Write Excel file in Java using Apache POI 2014-04-18 BY DINESH LEAVE A COMMENT About a year o ...

  6. The 13th tip of DB Query Analyzer, powerful processing EXCEL file

    The 13thtip of DB Query Analyzer, powerful processing EXCEL file MA Genfeng (Guangdong UnitollServic ...

  7. How to create Excel file in C#

    http://csharp.net-informations.com/excel/csharp-create-excel.htm Before you create an Excel file in ...

  8. Apache POI – Reading and Writing Excel file in Java

    来源于:https://www.mkyong.com/java/apache-poi-reading-and-writing-excel-file-in-java/ In this article, ...

  9. A simple way to crack VBA password in Excel file

    Unbelivibale, but I found a very simple way that really works! Do the follwoing: 1. Create a new sim ...

随机推荐

  1. JQuery_事件基础

    JavaScript 有一个非常重要的功能,就是事件驱动.当页面完全加载后,用户通过鼠标或键盘触发页面中绑定事件的元素即可触发. jQuery 为开发者更有效率的编写事件行为, 封装了大量有益的事件方 ...

  2. JDBC总结(含DbUtils组件)

    jdbc1. jdbc:使用java代码(程序)发送sql语句的技术2. jdbc的核心接口(查看API): java.sql Driver,DriverManger,Statement,Result ...

  3. miniui datepicker 二次加工

    function onshowpopup(){ $(".mini-calendar-timespinner").css({"width":"180px ...

  4. 移动端html模版

    <!DOCTYPE html><html><head> <title>时钟</title> <meta charset="u ...

  5. MongoDB 备份(mongodump)与恢复(mongorestore)

    MongoDB数据备份 在Mongodb中我们使用mongodump命令来备份MongoDB数据.该命令可以导出所有数据到指定目录中. mongodump命令可以通过参数指定导出的数据量级转存的服务器 ...

  6. VHDL的参数写在一个vhd文件里

    1 参数文件top_pkg.vhd

  7. VA01复制单据,更新定价日期和价格

    用户经常复制单据,而复制单据的时候会带过来很多日期的历史数据.定价日期就是其中之一,而价格经常变动,或者删除的话,会出现价格错误等等情况. 1.更新定价日期,保证不会使用历史价格. 2.更新价格,保证 ...

  8. Sample a balance dataset from imbalance dataset and save it(从不平衡数据中抽取平衡数据,并保存)

    有时我们在实际分类数据挖掘中经常会遇到,类别样本很不均衡,直接使用这种不均衡数据会影响一些模型的分类效果,如logistic regression,SVM等,一种解决办法就是对数据进行均衡采样,这里就 ...

  9. 使用Autolayout对多行文本Label进行布局,高度不准确的解决办法!

    BUG描述: 今天公司的项目中发现了一个BUG,大概给大家描述一下,tabbleView有一个tableFooterView,这个footView中有一个Label,是多行显示文本,程序用的是Auto ...

  10. 一个面试题的解答-----从500(Id不连续)道试题库里随机抽取20道题!

    做一个考试系统的项目,现在从试题库里面随机抽取20道题 比如我题库有500道题(ID不连续).题目出现了,如何解决呢,随机抽取! 1,我们先把500道题的id存进一个长度为500的数组. 2,实现代码 ...