Read Excel file from C#
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#的更多相关文章
- 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 ...
- csharp:using OpenXml SDK 2.0 and ClosedXML read excel file
https://openxmlexporttoexcel.codeplex.com/ http://referencesource.microsoft.com/ 引用: using System; u ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- How to create Excel file in C#
http://csharp.net-informations.com/excel/csharp-create-excel.htm Before you create an Excel file in ...
- 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, ...
- 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 ...
随机推荐
- js跨域_jsonP
$.ajax("url", type:"get", dataType:"jsonp", jsonp:"callback" ...
- ExtJS Grid导出excel文件
ExtJS Grid导出excel文件, 需下载POI:链接:http://pan.baidu.com/s/1i3lkPhF 密码:rqbg 1.将Grid表格数据连同表格列名传到后台 2.后台导出e ...
- ws_ webpack+reactjs+redux+nodejs认识
/** * Created by yangpu on 2016/9/18. */ //环境安装方法1.npm install //加载依赖模块2.npm run build //打包没有压缩,开发环境 ...
- 用Nginx+Lua(OpenResty)开发高性能Web应用
在互联网公司,Nginx可以说是标配组件,但是主要场景还是负载均衡.反向代理.代理缓存.限流等场景:而把Nginx作为一个Web容器使用的还不是那么广泛.Nginx的高性能是大家公认的,而Nginx开 ...
- 关于css
已经学了四天的css.现在对于css的了解还很肤浅,首先,我对基础的还不是很了解. 级联样式表(Cascading Style Sheet)简称“CSS”,通常又称为“风格样式表(Style Shee ...
- C# Out,Ref 学习总结
C# Out,Ref 学习总结. ref是传递参数的地址,out是返回值,两者有一定的相同之处,不过也有不同点. 使用ref前必须对变量赋值,out不用. out的函数会清空变量,即使变量已经赋值也不 ...
- Rigid motion segmentation
In computer vision, rigid motion segmentation is the process of separating regions, features, or tra ...
- WEBSTORM 2016.3 activation code激活
选择activation code 激活方式,复制粘贴下面的激活码43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIjoi ...
- 无废话WCF入门教程六[一个简单的Demo]
一.前言 前面的几个章节介绍了很多理论基础,如:什么是WCF.WCF中的A.B.C.WCF的传输模式.本文从零开始和大家一起写一个小的WCF应用程序Demo. 大多框架的学习都是从增.删.改.查开始来 ...
- oracle异常:ORA-01422: exact fetch returns more than requested
ORA-01422: exact fetch returns more than requested 神奇的错误,困扰了我一个下午. 问题描述:明明只有一行记录,结果是报了多条记录的错误.令我百思不得 ...