Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello All,

I have Question in Javascript, I have one report and i want to export those report into Exccel whenever i click on the button. When i open the Export to Excel button it shows the Blank Screen but it seems that it is working fine for Desktop machines.

Here is the Code Snippet, Can you please help me on this

What I have tried:

C#
var exportXML = strxml;
response.setContentType('PLAINTEXT', 'ExcelResults.xls', 'attachment');
				response.write(exportXML);
Posted
Updated 8-Aug-16 9:39am

1 solution

Its in VB but you should be able to convert.

VB
Response.AddHeader("content-disposition", "attachment; filename=""" & strFileName & """")
Response.ContentType = "application/vnd.ms-excel"

Response.Charset = ""

Response.ContentEncoding = Encoding.UTF8

' Turn off the view state.
EnableViewState = False

Response.Clear()
Response.Write(strExcelFileContents) 'Your Excel file

' End the response.
Response.End()
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900