asp.net mvc - Export data to Excel template c# -


i have report template : enter image description here

i should how export data excel files same image.

you should not install excel on server seen solution. 1 straightforward way create download csv file. open in excel on client computer. following method shows how this:

public actionresult downloadselectedreport(int reportid) {     string filename = string.format("downloadlist{0:yymmdd}.csv", datetime.today);     memorystream memstream = new memorystream();     unicodeencoding uniencoding = new unicodeencoding();     byte[] reportstring = uniencoding.getbytes(buildreportascsv(reportid));     memstream.write(reportstring, 0, reportstring.length);     return file(memstream.toarray(), "application/vnd.ms-excel", server.urlencode(filename)); } 

use buildreportascsv(reportid) generate report downloading.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -