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. 要当好JavaScript程序员:5个debug技巧

    我一直使用printf调试程序,一般来说都是比较顺利,但有时候,你会发现需要更好的方法.下面几个JavaScript技巧相信你一定会觉得十分有用: 1. debugger; 我以前也说过,你可以在Ja ...

  2. JQuery_表单选择器

    表单作为HTML 中一种特殊的元素,操作方法较为多样性和特殊性 开发者不但可以使用之前的常规选择器或过滤器,也可以使用jQuery 为表单专门提供的选择器和过滤器来准确的定位表单元素. 一.常规选择器 ...

  3. 【图像】Matlab图像标定工具箱

    参考教程: Matlab工具箱教程  http://www.vision.caltech.edu/bouguetj/calib_doc/ 摄像机模型  http://oliver.zheng.blog ...

  4. Nginx的第一个模块-HelloWorld

    麻雀虽小,五脏俱全,小小的Hello World盛行于程序世界,就在于其代码虽短,但要真正运行起来,需要我们略通基本语法,稍懂编译运行环境,知晓操作过程,最后,还有一颗持之以恒,不怕折腾的心.前一阵子 ...

  5. [WPF]UserControl的MouseWheel事件触发

    用户控件: <UserControl> <Grid> <TextBox x:Name="textBlock" HorizontalAlignment= ...

  6. 解决NGUI自动被设置LYAER

    解决NGUI自动被设置LYAER uiwidget.cs1011行public void checklayer()这里修改 可以让LAYER不跟随父物体变动 但是这里有个问题 摄像机的CULL 不会被 ...

  7. MySQL DDL 整理

    DDL is Data Definition Language statements. Some examples:数据定义语言,用于定义和管理 SQL 数据库中的所有对象的语言 -- 清空表内容 T ...

  8. python+selenium安装步骤

    1.先安装python 2.下载setuptools 使用方法是在 命令提示符(cmd)下 输入 "easy_install包名称" 3.安装pip 4.安装selenium如果是 ...

  9. 查看Linux是32位还是64位

    最直接简洁的办法: 在linux终端输入getconf LONG_BIT命令 如果是32位机器,则结果为32 [root@localhost ~]# getconf LONG_BIT 32 如果是64 ...

  10. 在Emacs 24.4中使用在线字典

    使用Emacs时经常需要查英语字典怎么办?切到浏览器查?太慢.我想到一个高效的解决方案,利用新发布的Emacs 24.4中的Web浏览器eww,在Emacs中集成一个在线字典,查询光标处的字,一键搞定 ...