简体   繁体   English

Excel库-.Net 4.0如何影响它

[英]Excel Library - How Does .Net 4.0 Affect It

I'm using the Microsoft.Office.Interop.Excel nuGet library to export an excel report from my application. 我正在使用Microsoft.Office.Interop.Excel nuGet库从我的应用程序导出Excel报告。 I noticed that I was receiving the below error running on certain machines. 我注意到我在某些计算机上运行时收到以下错误。 My initial speculation was that there was a mismatch in version number somewhere between the OS or installed version of excel on the machine running the tool. 我最初的猜测是,操作系统或运行该工具的计算机上已安装的excel版本之间的版本号不匹配。 But then when I changed from .Net 3.5 to 4.0 this error went away regardless of OS version or excel version installed. 但是,当我从.Net 3.5更改为4.0时,无论安装的是OS版本还是excel版本,此错误都会消失。

So I'm up and running but I have been unable to find details of how the updated framework has caused this to suddenly work on all configurations. 因此,我已经启动并正在运行,但是我无法找到有关更新后的框架如何使它突然在所有配置上起作用的详细信息。 Out of curiousity, could someone explain or point me in the direction of an explaination? 出于好奇,有人可以向我解释或指出我的解释方向吗?

错误

The Microsoft.Office.Interop.Excel package depends on Excel being installed on the machine, since it's just a translator (called an Interop Assembly) to help you talk to Excel. Microsoft.Office.Interop.Excel程序包取决于计算机上安装的Excel,因为它只是帮助您与Excel对话的转换器(称为Interop程序集)。 It does not work when Excel is not there to talk to. 当不存在Excel时,它不起作用。 To have a more robust solution with working with Excel files from code, have a look at ClosedXML . 要获得使用代码中的Excel文件的更强大的解决方案,请查看ClosedXML

ClosedXML makes it easier for developers to create Excel 2007+ (.xlsx, .xlsm, etc) files. ClosedXML使开发人员更容易创建Excel 2007 +(。xlsx,.xlsm等)文件。 It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. 它提供了一种很好的面向对象的方式来处理文件(类似于VBA),而无需处理XML文档的麻烦。 It can be used by any .NET language like C# and VisualBasic.NET. 它可以由任何.NET语言(例如C#和VisualBasic.NET)使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM