Click here to Skip to main content
14,733,966 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 24-Nov-10 5:44am
v2
Comments
JF2015 24-Nov-10 10:45am
   
Ok, if you want us to be specific in answering you we could at least wish you to also be specific in asking: "certain data" ... "some methods"!
Gautham Gorla 24-Nov-10 11:11am
   
I really dint mean that but let me say what I have I have a storedprocedure I need to invoke that stored procedure in WCF and then display that rows in my Excel sheets..
ARopo 24-Nov-10 11:50am
   
It is not clear where WCF fits into this, Do you want to get rows from a database, send them over some network/internet then display the results in excel? Or just get rows from a database and display them in excel?

1 solution

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
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900