asp.net mvc - Export data to Excel template c# -
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
Post a Comment