自动化脚本将MS-Excel文件的数据与MS-ACCESS文件进行比较



我需要创建一个自动化脚本。我将获得一个MS Excel文件和一个MS-ACCESS文件。脚本将读取来自Excel和访问文件的数据,比较它们,并且具有不同值的行将与内容打印出来。我应该如何继续?需要哪种工具?

您可以使用OLEDB读取两个文件。我会将每个数据的数据分解为字典,其中键是列名,然后迭代一个,然后检查另一个。您甚至可以通过交换迭代来对其进行仔细检查。

Dictionary<String, String> resultsExcel = read(); //whatever you use to read it, could be OleDB, but there are multiple ways of reading an excel file in C#.
Dictionary<String, String> resultsAccess = read(); //whatever you use to read it.  Probably will be OleDB for this one.
//Iterate over each, checking the other's data, and storing the rows that are different.

,如果您使用OLEDB,您也可以与SQL进行整个比较。不确定,但可能是可能的。

最新更新