如何在 IIS 上启用读取 C# Excel 文件(在运行 IIS 的机器上本地读取它们工作正常)? [英] How to enable reading C# Excel files on IIS (reading them locally on the machine where IIS is running works fine)?

查看:49
本文介绍了如何在 IIS 上启用读取 C# Excel 文件(在运行 IIS 的机器上本地读取它们工作正常)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 中读取 Excel 文件时出现问题 'Microsoft.Jet.OLEDB.4.0' 提供程序未在本地计算机上注册.'Microsoft.ACE.OLEDB 相同.12.0'.这只发生在我在 IIS 上运行我的应用程序时.在运行 IIS 的机器上本地运行它可以正常工作.

Got a problem with reading Excel files in C# The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine., same for 'Microsoft.ACE.OLEDB.12.0'. that only occurs when I run my app on IIS. Running it locally on the machine where IIS is running works fine.

有问题的机器在 Win2003 R2 Enterprise x64 上运行.我在 VS2010,ASP.Net 4.0 中开发.

The machine in question runs on Win2003 R2 Enterprise x64. I develop in VS2010, ASP.Net 4.0.

看起来这个问题有两种解决方案:安装一些东西(首选)或切换到 32 位模式.我想了解这两种解决方案的含义,因为这些服务器上还运行着其他应用程序,而更改服务器需要花费大量时间并且非常痛苦.

It looks like there are 2 types of solutions to this problem: either install something (preferred) or switch to 32bit mode. I'd like to understand the implications of both solutions because there are other apps running on these servers and changing servers takes a lot of time and is very painful.

  1. 可以安装 Microsoft Access Database Engine 2010 Redistributable 改变局面?也许我应该安装另一个版本/其他东西?来源:http://www.arboundy.com/2010/11/the-microsoft.ace.oledb.12.0-provider-is-not-registered-on-the-local-machine/莉>
  2. 是否遵循 http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/405f5bb5-87a3-43d2-8138-54b75db73aa1.mspx?mfr=true 表示所有应用程序都在此服务器将在 32 位模式下运行?如果我将应用程序的设置从 64 更改为 x86,是否有必要这样做?我目前的配置是Any CPU",如果我把它设置为 32 位,我会失去什么?
  3. 似乎有第三种解决方案,将 dll 直接放入我的应用程序中.这是一个好的解决方案吗?应该是哪个dll?
  1. Can installation of Microsoft Access Database Engine 2010 Redistributable change the situation? Maybe I should install another version/something else? Source: http://www.arboundy.com/2010/11/the-microsoft.ace.oledb.12.0-provider-is-not-registered-on-the-local-machine/
  2. Does following the instructions on http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/405f5bb5-87a3-43d2-8138-54b75db73aa1.mspx?mfr=true mean that all applications on this server will run in 32bit mode? Is it necessary to do it if I change the settings of my application from 64 to x86? My current configuratios is "Any CPU", what do I lose if I set it to 32bit?
  3. there seem to be a third type of solution, to put a dll directly in my app. Is it a good soluion? Which dll it should be?

推荐答案

我目前正在一个项目中使用 Excel,据我所知,将 dll 添加到项目中是很好的,尤其是如果您无法控制什么你可以安装在服务器上.我知道一个大型项目就是这样做的.Microsoft 建议在部署服务器上安装 Excel 并使用 Interops,这听起来像您正在尝试执行的操作.

Hi I am working with Excel at the moment in a project, from what I know adding the dll to the project is fine especially if you have no control over what you can install on the server. I know of a large project that does it like that. Microsoft recommend installing Excel on the deployment server and using Interops, which sound like what you are trying to do.

我无法将 excel 安装到我们的部署服务器上,因为我们必须与其他项目共享它,所以我使用了 EPPlus 可在 nuget 上使用,并且非常易于设置和使用.用它生成 Excel 文件只用了不到一个小时.它的唯一缺点是它只生成 xlsx 文件,这些文件是较新类型的 excel 文件.

I wasn't able to install excel onto our deployment server because we have to share it with other projects so I used EP Plus which is available on nuget and extremely easy to set up and use. It took less than an hour to have it generating Excel files. The only drawback with it is that it only generates xlsx files which are the newer type of excel files.

这是一种更简单的方法,它可能更容易并适合您的项目.如果您想查看,他们的网站上有大量示例代码.这只是您的另一种选择,希望对您有用.

This is an easier approach and it may be easier and suitable for your project. There's loads of sample code on their website if you want to check it out. This is just another option for you, hopefully it is useful to you.

这篇关于如何在 IIS 上启用读取 C# Excel 文件(在运行 IIS 的机器上本地读取它们工作正常)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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