0

I am trying to convert a .ASPX file to a .XLS file.

The file gets downloaded with the data with a row count (17K records) and the actual data in DATAGRID is (20K records).

And if I manually copy the records from DATAGRID and paste it in Excel, all records gets pasted all (20K records).

Please find the below code which executes to download the Excel (.xls) file.

    Response.ClearHeaders()
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader("Content-Disposition", "attachment; filename=Test.xls")
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
PrasadK
  • 25
  • 5
  • 1
    Start using a specialized library for creating Excel files, like [EPPlus](https://github.com/JanKallman/EPPlus). [Example here](https://stackoverflow.com/a/47293207/5836671) and [here](https://stackoverflow.com/questions/52002573/send-excel-email-attachment-c-sharp). All you are doing now is creating a HTML page with an .xls extension. – VDWWD Jan 04 '21 at 14:23
  • I have a aspx page...now i want to download this page in excel format on a button click...how to do this??? i have to download both table & Datagrid control in one page and Datagrid will be having dynamic column also – PrasadK Jan 05 '21 at 08:00

0 Answers0