验证Excel工作表 [英] Validate excel worksheets

查看:72
本文介绍了验证Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有的问候,



我有一个奇怪的问题,到目前为止谷歌并没有那么有用。



我有一个项目,我一直在为我的工作而努力。基本上我正在将旧的VB6代码重写为更现代的C#(标准等)。我不能在细节方面给予太多,但我的问题不在于此。原始代码会摄取一堆不同的excel文件,导入数据并用它来处理。



不幸的是,这些数据非常不可靠。字段将丢失或拼写错误。单个单元格中的数据无效或缺失。将包括两个或三个非常类似命名的字段(当然只有一个是有效的)。添加新字段或删除旧字段时,格式也会随时间而变化。通常没有人提前让我们知道。



这真是恶化,但不幸的是,给我们输入数据的实体不会开始给我们任何体面的一致数据时间很快。当出现未计划的事情时,这会导致代码深处出现很多问题。



我可以使用EPPLUS和Dapper等技术轻松读取数据。但我想做的是能够在进入系统之前查看电子表格,并根据我们期望的内容验证电子表格的内容。这样,如果电子表格包含不良数据,我们可以拒绝它,最好提示用户让他们知道他们需要修理什么。



大概这样做,那里需要某种模式来描述数据应该是什么样子。但这些excel文件的形式各不相同。我想知道是否有可用的库已经这样做了,因为我不需要从头开始构建我自己的系统。



有没有人完成这样的吗?



谢谢,

Eiredrake



我尝试了什么:



EPPLUS和Dapper以及各种扩展。

解决方案

考虑到工作簿几乎可以包含任何内容,我不知道任何人都可以想出一个通用解决方案来满足您对其内容有效性的好奇心。



最好你想出一个你坚持让客户使用的标准工作簿。



如果那是不可能的,那么你就生活在混乱之中。


Quote:

我想知道是否有可用的库已经可以做到这一点因为我宁愿不必建造我自己的系统从零开始。





嗯......你必须从头编写自己的系统。


Greetings all,

I have an odd problem and google hasn't been all that helpful so far.

I have a project that I've been working on for my job. Essentially I am re-writing old school VB6 code into more modern C# (standard etc). I can't give too much in the way of details but the short of my issue is. The original code ingests a bunch of different excel files, imports the data and does stuff with it.

Unfortunately this data is notoriously unreliable. Fields will be missing or misspelled. Data will be invalid or missing in individual cells. Two or three very similarly named fields will be included (and naturally only one is valid). The format has also changed over time when new fields have been added or old fields removed. Usually without anyone letting us know ahead of time.

It's damned aggravating but unfortunately the entity giving us the input data isn't going to start giving us decent consistent data any time soon. This causes a lot of problems deep in the code when something comes up that wasn't planned for.

I can easily read the data using technologies such as EPPLUS and Dapper. But what I'd like to do is be able to look over the spreadsheet BEFORE it gets into the system and validate the contents of the spreadsheet against what we're expecting. That way if the spread sheet contains bad data we can refuse it and preferably prompt the user to let them know what they need to fix.

Presumably to do this, there would need to be some sort of schema describing what the data should look like. But the forms of these excel documents are varied. I'm wondering if there are any libraries available out there that already do this as I'd rather not have to build my own system from scratch.

Has anyone done anything like this?

thanks,
Eiredrake

What I have tried:

EPPLUS and Dapper along with various extensions.

解决方案

Considering that a work book can contain practically anything, I don't see how anyone can come up with a "generic" solution to satisfy your curiosity as to the "validity" of its content.

Better you come up with a "standard" workbook that you insist the client uses.

If that's not possible, then you live with the mess.


Quote:

I'm wondering if there are any libraries available out there that already do this as I'd rather not have to build my own system from scratch.



Well... you have to write your own system from scratch.


这篇关于验证Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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