Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fastest Method to get data from database to excel (C#)

Status
Not open for further replies.

leto100

Programmer
Aug 18, 2009
2
US
I have quite a bit of data in a database that needs to be transferred to excel, I was wondering what would be the fastest way to do this in C#?

Datatable then add data cell by cell,
Datatable to array then add to range of cells,

etc... So many options...
 
ETL (Extract Transform Load)

I have seen 2 implementations of this SSIS (MS) and Rhino.ETL (OSS). I favor Rhino.ETL as it's part of the Rhino.Tools stack and is easily testable.

If you don't have Access to SSIS and you don't want to figure out Rhino.ETL. Then your options are limited. One thing to consider is the amount of data. It may be beneficial to query the database in chunks rather then select all records at once and pull into memory.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
I am not sure if SSIS will work because I don't think generic users can call SSIS packages without much permission hassles.

I have a winforms application, and a user would select which report they want to publish to excel. Thus, some paramters would need to be passed to the SSIS package. There also would be some runtime formatting and data placement logic to take into account.

To keep it coupled with my application, I was thinking of just using the Microsoft.Office.Interop.Excel assembly in my winforms application. Thoughts?
 
the details of how you get the data into excel aren't really important. whether you use the Excel Interop assemblies, XML for XLS, or some other 3rd party library, it just an implementation detail.

I think your biggest concerns are:
1. how much data at any given time must be feed into Excel?
2. how often will this need to happen?
3. how current does the data have to be?

if you are talking about 100,000+ records. then this probably should not be done real-time. Either run this offline (non-core business hours) or near time, using some async techniques.

is this operation hourly, daily, weekly, monthly, sporadic, at a users discretion? If it doesn't happen that often then you could let this happen in the background. No need to have the actual computation on every single client.

do you need real-time, near-time or some other freshness of data? real time being right now. near-time being close to now as possible without making the user wait. Or, do you need records dated last month? in that case you could have a windows service create the file on the 1st of every month for the previous month. then the user just downloads the file. they don't need to wait for computation.

those are my thoughts anyway.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top