Wosh
Wosh

Reputation: 1625

Parallel write to Excel file c#

From some time I am struggling with exporting data from db (stored procedures) to excel files. As I am working with loads of data (around 500k rows per sheet, business requirement unfortunately) I was wondering whether there is the possibility to execute parallel writes to a single worksheet. I am using EPPlus and OpenXML for writing to the files. As I was reading through the web, I was able to understand that the User Defined Functions can be executed in parallel, but I didn't found anything for parallel writing. Any help/advice/hint/etc. will be much appreciated!

Upvotes: 2

Views: 2930

Answers (2)

Jnavero
Jnavero

Reputation: 363

To my knowledge, no. You can program it, but it's a hell

If You want to export to Excel fastly I think that you have two ways.

  1. CVS (fields separated by semicolon).
  2. Use Excel with ADO. You can insert registers with Sql Sentences.

More info:

MSDN: How To Transfer Data from ADO Data Source to Excel with ADO

StackOverflow: ado in excel, inserting records into access database

Upvotes: 6

Rabi
Rabi

Reputation: 2220

Unfortunately, you'll not be able to write to a single file in parallel. A better way is to create separate files (you can write to them in parallel :)) and finally merge the sheets to get a single document. you can do that using OpenXML. Here is an example - http://blogs.technet.com/b/ptsblog/archive/2011/01/24/open-xml-sdk-merging-documents.aspx

Well, parallel would be ambiguous, I'm thinking of multi-threading which is concurrent.

Upvotes: 2

Related Questions