C# - 比较两个excel文件 [英] C# - compare two excel files

查看:391
本文介绍了C# - 比较两个excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





我期待比较两个excel文件并将差异放到另一张表中。我遇到的主要问题是我不知道应该从哪里开始。



我搜索了google / sw develeopers论坛,我找不到我能用的东西比较2张。



我正在尝试这样做,比较一下WinForm应用程序,我被困在这部分。我甚至不知道我应该怎样接近这个..



有什么建议吗?代码示例??我将不胜感激!



我的尝试:



一切我在互联网上看过,但根本不适用于我的代码。

Hello everyone,


I am looking forward to compare two excel files and put the difference into another sheet. The main problem i encounter is that i do not know where i should start.

I have searched google/sw develeopers forums and i didn't find something i could use to compare 2 sheets.

I am trying currently to do this compare into a WinForm App and i'm stucked at this part. I do not even know how should i approach to this ..

Any suggestions ?? Code example ?? I would be grateful !

What I have tried:

Everything i have seen on internet but doesn't apply at all to my code.

推荐答案

首先将你的excel表格放入Datatable,如下所示如何在C#中将Excel转换为DataTable [ ^ ]



然后比较这样的数据表如何比较两个数据表并创建一个新的数据表基于比较结果(c#)| ASP.NET论坛 [ ^ ]
First get your excel sheets into Datatable like this How to Convert Excel to DataTable in C#[^]

Then compare your datatable like this How to compare two data tables and create a new data table based on the compared results (c#) | The ASP.NET Forums[^]


当你谷歌 excel比较表,你只得到1500万个答案,你发现什么没有用?严重?

When you Google "excel compare sheets", you get only 15 million answers, and you found nothing useful ? Serious ?
Quote:

我期待比较两个excel文件并将差异放到另一张表中。

I am looking forward to compare two excel files and put the difference into another sheet.

首先你需要定义你要比较的内容,单元格值,公式,格式......

First you need to define what you want to compare, cells values, formulas, formatting ...

引用:

我遇到的主要问题是我不知道应该从哪里开始。

The main problem i encounter is that i do not know where i should start.

你在开玩笑吧?有几种方法可以做到这一点。

你想告诉你的用户差异在哪里。

对于2张第一张纸的每个单元格,你想要tp写如果单元格相同或不同,则在第三张表格中。

或多或少,您将拥有:

Are you kidding ? There is pretty much one way to do it.
You want to tell your user where are the differences.
For each cells of the 2 first sheets, you want tp write in third sheet if the cells are equal or not.
More or less, you will have:

' not real code
Sheet3.A1=(Sheet1.A1=Sheet2.A1)



详细信息因您希望如何显示差异以及您要查找的差异而有所不同。


details vary on how you want to show differences and what differences you looking for.

引用:

我搜索了google / sw develeopers论坛,我没有找到可以用来比较2张的东西。

I have searched google/sw develeopers forums and i didn't find something i could use to compare 2 sheets.

有时,你必须努力维持生计。

当你找到一种语言的解决方案时,你的工作就是用你的语言翻译并适应你的标准。

Sometimes, you have to work to make ends meet.
When you found a solution in a language, your jobs is to translate in your language and adapt to your criteria.

Quote:

我在互联网上看到的所有东西,但根本不适用于我的代码。

Everything i have seen on internet but doesn't apply at all to my code.

程序员不只是一个复制/粘贴工作,有时你必须创建东西。

Programmer is not just a Copy/Paste job, sometimes you have to create things.


我正在做一些几乎完全相同的事情(WPF应用程序)。我正在使用两个电子表格,并根据用户指定的映射条件(使用一个或多个匹配的列对)合并它们。



我正在使用向导 - 样式表格引导用户完成整个过程。我的向导页面是:



- 简介

- 选择合并类型(两个文件,或单个文件中的两个工作表)

- 文件(和工作表)选择

- 列选择

- 匹配条件

- 新(合并)文件生成/预览/保存
I'm doing something almost exactly like that (WPF application). I'm taking two spreadsheets, and merging them based on a user-specified mapping criteria (with one or more matching column pairs.

I'm using a Wizard-style form to guide the user through the process. My wizard pages are:

- Introduction
- Selecting a merge type (two files, or two worksheets in a single file)
- File (and worksheet) selection
- Column selection
- Matching criteria
- New (merged) file generation/preview/save


这篇关于C# - 比较两个excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆