如何使用wpf读取和写入excel文件 [英] how to read and write into excel files with wpf

查看:68
本文介绍了如何使用wpf读取和写入excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我知道这听起来很容易,但我已经尝试过但我已经尝试了但是我只是卡在中间的地方没有,所以,我希望能够读到一个Windows演示基础应用程序中的大型多个excel文件,我可以编辑这些文件。



我无法理解选择哪条路径或我该怎么做我真的被困了,因为Windows窗体的解决方案无法正常工作,对于wpf而言,它并没有带来我想要利用它的Windows演示基础技术的最佳效果。



谢谢

Hi,
I Know this sounds easy but I've tried and I've tried but i'm just stuck in the middle of no where so , I want to be able to read a large multiple excel files in a windows presentation foundation application and i can edit this files.

I can't make mind of which path to choose or what should i do i'm really stuck because solutions for windows forms doesn't work, most of the times , for wpf and it doesn't bring the best out the windows presentation foundation technology which i want to take advantage from it.

Thanks

推荐答案

它与WPF无关,正如我在对该问题的评论中已经提到的那样。三种最常用的方法是:1)使用Office互操作程序集,2)使用Open XML SDK,3)使用第三方产品,主要基于Open XML标准并直接形成.xslx数据结构文件。



我建议使用Open XML SDK。请参阅此处引用的过去的答案:如何从MS Visual中添加参考添加microsoft excel 15.0对象库Studio 2010 [ ^ ] 。



请参阅CodeProject成员Mika Wendelius的回答:使用Open XML创建基本的Excel工作簿 [ ^ ]。



请参阅Microsoft警告不要使用互操作程序集在某些设置中:

http:// support。微软。 com / default.aspx?scid = kb; EN-US; q257757 #kb2 [ ^ ],

http://support.microsoft.com/kb/257757/en-us [ ^ ]。



祝你好运,

-SA
It is not related to WPF, as I already noted in my comment to the question. Three most usual approaches are: 1) using Office interop assembly, 2) using Open XML SDK, 3) using 3rd-party products, mostly based on Open XML standard and directly forming the file of .xslx data structure.

I would recommend using Open XML SDK. Please see my past answers referenced in this on: How to add microsoft excel 15.0 object library from Add Reference in MS Visual Studio 2010[^].

See also this answer by Mika Wendelius, CodeProject member: Creating basic Excel workbook with Open XML[^].

Please see Microsoft warnings against using interop assemblies in certain settings:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

Good luck,
—SA


如果说'大型Excel文件',你的意思是包含结构化数据的文件,我建议你使用ADO.NET [ ^ ]。



更多:

如何使用ADO.NET使用Visual Basic .NET在Excel工作簿中检索和修改记录 [ ^ ]

从.NET应用程序访问Microsoft Office数据 [ ^ ]

使用ADO.NET处理Excel文件 [ ^ ]



和......最好的链接集合:

使用ADO和ADO.NET与EXCEL:资源和已知问题 [ ^ ]



WPF相关链接:

使用WPF,WCF和LINQ构建基于Office的解决方案 [< a href =http://msdn.microsoft.com/en-us/magazine/cc163292.aspxtarget =_ blanktitle =新窗口> ^ ]

在Office解决方案中使用WPF控件 [ ^ ]
If by saying 'large Excel files', you mean files containing structured data, i suggest you to use ADO.NET[^].

More:
How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET[^]
Accessing Microsoft Office Data from .NET Applications[^]
Using ADO.NET to work with Excel files[^]

And... the best collection of links:
USING ADO AND ADO.NET WITH EXCEL: Resources and Known Issues[^]

WPF related links:
Build Office-Based Solutions Using WPF, WCF, And LINQ[^]
Using WPF Controls in Office Solutions[^]


启动Excel并让Excel完成工作?

为什么要在wpf应用程序中模拟所有过滤,排序,公式编辑等?



或者使用一个可用的组件读取和写入*文件*,例如 http://www.tmssoftware.com/site/flexcelnet.asp [ ^ ]并且只提供一个简单的网格编辑器。 />


我们不知道您的*真实*要求是什么 - 根据您的要求,您打开潘多拉盒子或它是一个简单的解决方案(或介于两者之间)。



例如你想要Excel的完整功能集,如所有编辑和错误处理,所有图形功能,所有关系和多张表等等?或者你只是想在数据网格中输入一些数据,没有排序,没有图形,没有过滤,没有花哨的东西?



干杯

Andi



PS:请停止抱怨。您没有向我们展示您的任何努力。这不是gimme解决方案的地方。没有明显的努力通常会导致无法回答。
Fire up Excel and let Excel do the work?
Why emulating all the filtering, sorting, formula editing, etc. in a wpf application?

Or use a commertially available component for reading and writing the *files*, like http://www.tmssoftware.com/site/flexcelnet.asp[^] and only provide a simple grid editor.

We have no clue what your *real* requirements are - depending on your requirements, you open up the box of Pandora or it's a simple solution (or somethin in between).

E.g. do you want the full feature set from Excel, like all editing and error handling, all graphics capabilities, all relations and multi sheets, etc. etc.? Or do you just want to enter some data in a data grid, no sorting, no graphics, no filtering, no fancy stuff?

Cheers
Andi

PS: And please stop "whining". You do not show us any of your effort. This is not the place for "gimme solution". No obvious effort from your side usually does result in no answer.


这篇关于如何使用wpf读取和写入excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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