简体   繁体   English

使用Selenium WebDriver进行自动化时,NPOI是否比C#中的Office Interop好?

[英]Is NPOI better than Office Interop in C# for automation using Selenium WebDriver

I am using C# and Selenium WebDriver for automating our web application. 我正在使用C#和Selenium WebDriver来自动化我们的Web应用程序。 The test data will be read from Excel sheets(.xlsx). 测试数据将从Excel工作表(.xlsx)中读取。 Being new to C#, I want to know if using NPOI is a good option to read/write data from Excel or using Interop in C# is a preferred. 作为C#的新手,我想知道使用NPOI是从Excel读取/写入数据的好选择还是在C#中使用Interop是首选。 I personally prefer NPOI as I feel it is easier to use. 我个人更喜欢NPOI,因为我觉得它更容易使用。 This could be because of my exposure to Apache POI when I used Java and Selenium for automation. 这可能是因为我在使用Java和Selenium进行自动化时接触过Apache POI。 Kindly help. 请帮助。

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment. Microsoft当前不建议也不支持任何无人参与的非交互客户端应用程序或组件(包括ASP,ASP.NET,DCOM和NT Services)中的Microsoft Office应用程序自动化,因为Office可能表现出不稳定的行为和/在此环境中运行Office时出现死锁或死锁。

https://support.microsoft.com/en-us/kb/257757 https://support.microsoft.com/zh-CN/kb/257757

Don't use Office Interop in web environments. 不要在网络环境中使用Office Interop。

Office文档自动化的Microsoft解决方案是Open Xml: https ://msdn.microsoft.com/zh-cn/library/bb448854( v= office.15).aspx

At first, as mentioned already, Interop requires actual Excel application to be installed on server, which is not always a good idea ar may even be not possible at all (ie if you are yousing Azure Web Apps). 首先,如前所述,Interop需要在服务器上安装实际的Excel应用程序,这并不是一个好主意,甚至根本不可能(例如,如果您正在使用Azure Web Apps)。 I'm currently working on a project which we have rewritten using Interop, but now are going to migrate to NPOI mainly because of it's speed: some tasks require around 5-8 seconds using Excel Interop, because it actually launches full Excel app and communicates with it via RPC. 我目前正在处理一个项目,该项目已使用Interop进行了重写,但现在由于其速度原因,现在将迁移到NPOI:使用Excel Interop某些任务大约需要5-8秒,因为它实际上会启动完整的Excel应用程序并进行通信通过RPC使用它。 NPOI works directly with Excel files and today while testing one heave action was performed in just around 300 milliseconds including saving modified workbook to new file. NPOI直接与Excel文件一起使用,今天,在测试一个举升动作的过程中,大约300毫秒就执行了一次,包括将修改后的工作簿保存到新文件中。 So if you have to work specifically with old binary .xls files NPOI is good choise. 因此,如果您必须专门使用旧的二进制.xls文件,则NPOI是不错的选择。 If you are going to work with modern OpenXML files (.xlsx), take a look at https://github.com/closedxml/closedxml 如果您要使用现代OpenXML文件(.xlsx),请查看https://github.com/closedxml/closedxml

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

相关问题 如何使用矢量 + Ms Graph 和 C# office interop 词库在词自动化中绘制图表(图表) - How to Draw diagrams (Charts) in word automation using vectors + Ms Graph with C# office interop word library C#Microsoft Word自动化Microsoft.Office.Interop.Word - C# Microsoft Word automation Microsoft.Office.Interop.Word 如何在“ Windows身份验证对话框”上应用自动化并使用c#,Selenium Webdriver登录到Web应用程序 - How to apply automation on “Windows authentication dialog” and login into the web application using c# , selenium webdriver 可以使用Selenium Webdriver和C#完成Android App自动化测试吗? - Can Android App automation testing be done using selenium webdriver and C#? Selenium webdriver C# 自动化脚本在边缘浏览器中不起作用 - Selenium webdriver C# automation script not working in edge browser 使用 C# 和 Office.Interop.Word 用多行替换文本 - Replace text with multilines using C# with Office.Interop.Word 使用Microsoft.Office.Interop使用C#保存创建的文件 - Using Microsoft.Office.Interop to save created file with C# 使用C#Interop清除/清空办公室剪贴板 - Clearing/Emptying office clipboard using C# Interop C#在不使用Office互操作的情况下创建Outlook任务 - C# Create Outlook task without using office interop 使用Microsoft.Office.Interop将C#html转换为docx - c# html to docx conversion using Microsoft.Office.Interop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM