WCF服务:将数据从数据库传输到Excel [英] WCF Services :Transfering Data from Database to Excel
本文介绍了WCF服务:将数据从数据库传输到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
有人可以帮我吗?
我有一些来自Database(sql 2005)的数据,并且使用WCF服务,我需要编写一些方法来通过创建数据来显示我在Excel工作表中所需的数据
你们任何人都可以请我解释一下该怎么做吗?
我是初学者,因此,如果可以的话,请尝试尽可能具体一些.
Hi Guys,
can anyone help me with this?
I have certain data coming from Database(sql 2005) and using the WCF Services I need to write some methods to show that data what I need in Excel sheets by creating them
Can any of you guys please explain me how this can be done?
I am a beginner so please try to be as specific as possible if you can.
推荐答案
你不想要调用一个sp.您只想执行它.
通过数据层或linq.
当您在应用程序中拥有数据时.您需要研究使用C#将数据写入excel"的方法-有2种方法-1种依赖关系,需要在要运行应用程序的位置安装Office-另一种是分发的dll. br/>
无论如何-您的DataTable-您将不得不遍历每个单元格/行/列以将所需的内容构建到excel工作表中.
可以将工作表追加"到现有文档.
否则-将特定的工作表"阅读到您的应用中.
在数据表中尽可能附加数据-将新工作表添加到excel文档中-删除先前的工作表-将新工作表重命名为先前的工作表.
-可能会有风险,因为其他工作表可能会引用此旧工作表.但是可行.
确保在错误处理程序中关闭excel文档-否则,您需要使用任务管理器将其杀死.
另外,请避免使用excel 2003或更少的API-每个工作表的限制为65K.
问候,
克里斯
Hi,
you dont'' want to invoke a sp. you just want to execute it.
by means of a data layer or linq.
when you have the data in the app. you''ll need to research "writing data to excel using c#" - there''s 2 ways - 1 with a dependency that office needs to be installed where your app will be running - the other is a dll that gets distributed.
Anyways - your DataTable - you''ll have to loop through each cell / row / column to build the content you want into the excel worksheet.
It is possible to "append" a worksheet to a existing document.
Otherwise - read the specific "worksheet" onto your app.
append your data where possible in the DataTable - add the new worksheet to the excel document - remove the previous worksheet - rename your new worksheet to the previous.
- Might be risky as other worksheets might have references to this old worksheet. But doable.
Make sure that you close the excel document in your error handler - Otherwise you need to use the task manager to kill it.
Also, avoid excel 2003 or less API''s - you have a 65K limit per worksheet.
Regards,
Chris
这篇关于WCF服务:将数据从数据库传输到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文