Select Case (svlType.ToLower)
Case "txt" : svlType = "text/plain"
Case "htm" : svlType = "text/HTML"
Case "html" : svlType = "text/HTML"
Case "pdf" : svlType = "Application/pdf"
Case "gif" : svlType = "image/GIF"
Case "jpg" : svlType = "image/JPEG"
Case "jpeg" : svlType = "image/JPEG"
Case "png" : svlType = "image/png"
Case "doc" : svlType = "Application/msword" ' (for Microsoft Word files)
Case "xls" : svlType = "Application/x-msexcel" '(for Microsoft Excel files)
End Select
HttpContext.Current.Response.ContentType =svlType
HttpContext.Current.Response.write(YourVariable)
YourVariable is the variable which holds data.
In case while saving if you expect the file to be saved in a filename you specify You can use
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & myFileName)
In the case with FileName, use it as follows:
HttpContext.Current.Response.ContentType =svlType
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" & myFileName)
HttpContext.Current.Response.write(YourVariable)
"Asha" wrote:
Greetings,
I’ve query some data from the table, how can I push it into an excel file and allow user to save it? anyone done this sort of thing before?