Streaming large amounts of data from sql server to an Excel file via c# web service -


so i'm trying results stored proc (200k rows+) excel file asp.net having few difficulties. don't think csv option client want numbers formatted correctly. i've tried 3 third party excel libraries have fallen on data , using gigabytes of memory.

i've wrote code generate excel xml file , runs file on 300megs. if open , save native excel file gets down 30megs. @ moment best solution zip xml file on server gets down 7megs user still going end huge file once unzipped. ideally i'd find third party excel library can write native excel file 200,000+ rows without killing server, ideas?

here's quick poc made writes 3 columns of 255 characters 200,000 times (600,000 cells). final file comes in @ 4.85mb on machine.

        string exportfile = system.io.path.combine(environment.getfolderpath(environment.specialfolder.desktop), "test.xlsx");         string dsn = string.format("provider=microsoft.ace.oledb.12.0;data source={0};extended properties=\"excel 12.0 xml;hdr=yes\";", exportfile);          using (system.data.oledb.oledbconnection con = new system.data.oledb.oledbconnection(dsn))         {             con.open();             using (system.data.oledb.oledbcommand com = new system.data.oledb.oledbcommand())             {                 com.connection = con;                 com.commandtext = "create table [testsheet] (a1 varchar(255), b1 varchar(255), c1 varchar(255))";                 com.executenonquery();                 string a1 = new string('a', 255);                 string b1 = new string('b', 255);                 string c1 = new string('c', 255);                 com.commandtext = string.format("insert [testsheet] (a1, b1, c1) values ('{0}', '{1}', '{2}')", a1, b1, c1);                 (var = 1; <= 200000; i++)                 {                     com.executenonquery();                 }             }             con.close();         } 

on server i'm not sure what's needed might have install this:

http://www.microsoft.com/downloads/en/details.aspx?familyid=7554f536-8c28-4598-9b72-ef94e038c891&displaylang=en


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -