简体   繁体   English

如何使用c#从XML文件读取特定数据并将其写入到现有Excel工作表

[英]How to Read a particular Data from XML file and Write it to an Existing Excel Sheet using c#

i have an xml file, i have some values like good, and bad, with Tag Quality. 我有一个xml文件,我对标签质量有一些好的和坏的值。 I want to read the xml file and print the ones which are Bad, in the Excel sheet which is existing. 我想读取xml文件并在现有的Excel工作表中打印错误的文件。 Can anyone help me Please. 谁能帮我。 My XML file looks same as Below. 我的XML文件如下所示。 So in that text i want to write entire HYDR. 因此,在该文本中,我想编写整个HYDR。 instrument id, HYDR.Quality" Only for Bad Values in HYDR.Quality Element. 仪器ID,HYDR.Quality”,仅适用于HYDR.Quality元素中的错误值。

<HYDR.Instrument id="ABR"> <HYDR.Quality>Good</HYDR.Quality> <HYDR.Value>0</HYDR.Value> </HYDR.Instrument> <HYDR.Instrument id="ABR_DUMMY"> <HYDR.Quality>Bad</HYDR.Quality> <HYDR.Value>0</HYDR.Value> </HYDR.Instrument> <HYDR.Instrument id="ABR_LOOP_JP"> <HYDR.Quality>Good</HYDR.Quality> <HYDR.Value>15.208 kg/cm2g</HYDR.Value> </HYDR.Instrument> <HYDR.Instrument id="ABR_MOV_12"> <HYDR.Quality>Good</HYDR.Quality> <HYDR.Value>0</HYDR.Value> </HYDR.Instrument>

Basically you need to use two libraries to get to the answer you want: 基本上,您需要使用两个库来获得所需的答案:

  1. First you need to load the XML file, so I suggest using the Linq library, you can start from here 首先,您需要加载XML文件,因此我建议使用Linq库,您可以从这里开始

  2. Then, you need to write the filtered XML elements to excel, I suggest to use the aspose library, you can start learning from here 然后,您需要将过滤后的XML元素编写为excel,我建议使用aspose库,您可以从此处开始学习

Using these two libraries, you can achieve what you want. 使用这两个库,您可以实现所需的功能。

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

相关问题 使用C#将数据从Excel工作表写入文本文件 - Write the data from an Excel sheet to the text file using C# 如何使用C#在特定单元格的Excel文件中写入数据 - How to write data in an excel file at particular cell using c# 如何使用C#从xml文件中检索特定数据 - How to retrieve particular data from xml file using c# 如何使用OpenXML C#将特定于Excel的行和工作表读取到数据表中 - How to read file excel row and sheet specific using openXML C# into data table 打开 XML:如何使用 c# 在现有 Excel 文件中追加新工作表后添加行和单元格值 - Open XML: How to add rows and cell value after appending new sheet in existing Excel file using c# C#如何使用Interop从Excel读取和写入数据,而不显示Excel? - C# How to read and write data from Excel using Interop, without making Excel visible? 如何使用 C# 中的 NPOI 从现有 excel 文件中的列表中写入元素? - How to write element from a list in a existing excel file using NPOI in C#? 可以使用样式表用数据填充现有的 Excel 工作表吗? C# - Can an existing Excel sheet be filled with data using stylesheet? C# 如何将数据导出到 C# 中已有的 excel 表? - How to export data to already existing excel sheet in C#? 如何使用C#将数据附加到现有的Excel文件 - How to append a data to existing excel file using c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM