c# - Export Linq query result to excel EPPLUS -


i have developed program linq query , write excel file using epplus (the below code) slow because filling file line line. there anyway fill excel file @ once? export query @ once excel file?

fnctndata query result

thanks help

public boolean generateexcel(ienumerable<reportdata> fnctndata,string filename,reportfilter smf)         {             boolean ret=false;             try             {                 string temp = path.getdirectoryname(appdomain.currentdomain.basedirectory);                 directoryinfo di = new directoryinfo(temp);                 string templatefile = path.combine(di.parent.fullname, @"templates\report.xlsx");                 fileinfo itemplatefile = new fileinfo(templatefile);                 fileinfo reportfile = new fileinfo(filename);                  using (excelpackage package = new excelpackage(reportfile,itemplatefile))                 {                      excelworksheet worksheet = package.workbook.worksheets.first();                       int = 5;                     foreach (var item in fnctndata)                     {                         worksheet.cells["a" + i].value = item.a;                         worksheet.cells["b" + i].value = item.c;                         worksheet.cells["c" + i].value = item.d;                         worksheet.cells["d" + i].value = string.format("{0:dd/mm/yyyy hh:mm:ss}", item.date);                         worksheet.cells["e" + i].value = item.e;                         worksheet.cells["f" + i].value = item.f;                         worksheet.cells["g" + i].value = item.g;                         i++;                     }                     package.saveas(reportfile);                     ret = true;                 }             }                catch (exception ex)             {                 librarylogger.loggersoftwareutility.error(string.format("generateexcel exception : {0}", ex));                 throw ex;             }             return ret;          } 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -