asp.net - Export Repeater to excel -
i trying export repeater excel , here code...
stringwriter sw = new stringwriter(); htmltextwriter htw = new htmltextwriter(sw); string attachment = "attachment; filename=file.xls"; response.clearcontent(); response.addheader("content-disposition", attachment); response.contenttype = "application/vnd.ms-excel"; rpt.rendercontrol(htw); response.write(sw.tostring()); response.flush(); response.end();
when trying open file getting error
the file trying open, 'file.xls', in different format specified file extension. verify file not corrupted , trusted source before opening file. want open file now? yes no option available
what's wrong in code or have resolve issue. thanks
you setting content type application/vnd.ms-excel
sending html contents in response stream when call rendercontents
method. might need library generate excel files.
Comments
Post a Comment