简体   繁体   English

将microsoft.office.interop.excel添加到Visual Studio 2015中不起作用

[英]adding microsoft.office.interop.excel to visual studio 2015 does not work

I currently making an inventory management system for thee company I am currently hired in. The system requires me to export data from DataGridView to Excel. 我目前正在为当前雇用的您的公司制作一个库存管理系统。该系统要求我将数据从DataGridView导出到Excel。 I have tried clicking "Add Reference" to my references in solution explorer and selecting Microsoft.Office.Interop.Excel but after I click OK it still is not in my references. 我尝试在解决方案资源管理器中单击“添加引用”到我的引用,然后选择Microsoft.Office.Interop.Excel但是单击“确定”后,它仍然不在我的引用中。 I tried it in my code but then I get this error: 我在我的代码中尝试过,但是随后出现此错误:

Error CS0234 The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) 错误CS0234类型或名称空间名称“ Office”在名称空间“ Microsoft”中不存在(您是否缺少程序集引用?)

There are other methods of generation Excel files from C# without using the ineterop. 还有其他方法可以使用C#生成Excel文件而不使用ineterop。 One of the best ways is Open XML 最好的方法之一是Open XML

It is not good to use this method. 使用此方法不好。 What if on somebody's computer there is not Excel? 如果某人的计算机上没有Excel怎么办? Try open source lib as EPPlus or as @Sagi mentioned Open XML 尝试将开放源代码库作为EPPlus或@Sagi提到的Open XML

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

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