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 ...
随机推荐
- CSS+Javascript
今天做了一个简单的CSS和Javascript的调用,发现CSS和Javascript系统的来写还真是蛮方便的. 1.先建一个CSS文件和一个JS文件 2.在jsp中调用 <link type= ...
- Forward和Redirect的区别
一:间接请求转发(Redirect) 二:直接请求转发(Forward) 用户向服务器发送了一次HTTP请求,该请求可能会经过多个信息资源处理以后才返回给用户,各个信息资源使用请求转发机制相互转发请求 ...
- Vs2010在C#类文件头部添加文件注释的方法
步骤: 1.VS2010 中找到(安装盘符以C盘为例) 32位操作系统路径:C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Item ...
- mysql安装innodb插件
可以用 show engines;或者show plugins;来查看mysql> show plugins;+------------+--------+----------------+-- ...
- AngularJS的$watch用法
$watch简单使用 $watch是一个scope函数,用于监听模型变化,当你的模型部分发生变化时它会通知你. $watch(watchExpression, listener, objectEqua ...
- office2003安装公式编辑器mathtype5.2
同事的一台电脑,xp系统,需要安装公式编辑器mathtype,安装完后,启动word时出现了宏的警告. 在菜单中,无论如何设置宏,都不能去除该提示框.删除了模板normal.dot,也不能解决该问题. ...
- 深度学习(DNN)的学习网站
近期决定对深度学习稍微学习一下,因此搜集了一些相关的网站和资料,特分享给大家. 首先,如果你对机器学习还不甚了解,最好先了解一下其相关的概念,推荐 Andrew Ng在斯坦福的机器学习教程 (中文翻译 ...
- document.all.wb.ExecWB
<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib uri=&quo ...
- google书签找回
解决办法: 1.查找google文件夹,win7为例子:C:\Users\ZhangSan\AppData\Local\Google\Chrome\User Data 找到这个文件夹,ZhangSan ...
- border家族
border-style:dotted solid double dashed(上边框是点状,右边框是实线,下边框是双线,左边框是虚线)边框样式;border-width(边框宽度);border-r ...