如何在ASP.NET C#应用程序中读取excel文件。 [英] How to read excel file in ASP.NET C# application.

查看:62
本文介绍了如何在ASP.NET C#应用程序中读取excel文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个控制台应用程序(Scheduler),它会定期触发电子邮件。



这里我想读一个excel文件,如何实现它。

一步一步解决方案将不胜感激,



不了解如何使用以下连接字符串 -



I am creating a console application (Scheduler) which triggers emails regularly.

here I want to read an excel file, how to implement this.
step by step solution will be appreciated,

Not understanding how to use the below connection string-

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;
Extended Properties="Excel 12.0 Xml;HDR=YES";





我尝试过:



这是我所指的文章实现这个: https://www.aspsnippets.com/Articles/Read-and-Import-Excel-Sheet-using-ADO.Net-and- C.aspx [ ^ ]

推荐答案

要使用它,您需要在您的计算机上安装Access ACE引擎V12,以及您正在使用的应用程序的正确版本:64位应用程序需要64位引擎; 32位应用程序需要32位版本。然后,您可以使用连接字符串构造OledbConnection对象,打开它,并使用OledbCommand对象来访问它,就好像它是一个数据库一样。



但是,有更简单的方法来读取XLSX文件: C#如何读取包含3行代码的.xlsx Excel文件 [ ^ ]例如。
To use that, you need to have the Access ACE engine V12 installed on your machine, and the correct version for the app you are using: a 64 bit app requires the 64 bit engine; a 32 bit app requires the 32 bit version. You can then use the connections string to construct an OledbConnection object, open it, and use OledbCommand objects to access it as if it was a database.

However, there are simpler ways to read XLSX files: C# How To Read .xlsx Excel File With 3 Lines of Code[^] for example.


这篇关于如何在ASP.NET C#应用程序中读取excel文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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