C# .NET - using Response.Redirect to open documents. working(txt,jpg,csv) but not xls or xlsx

Asked By Pranay on 12-Feb-13 02:04 PM
I'm trying display documents stored in a folder(@ server) through my application. I'm response.redirect and its working fine for txt, jpg, and csv files but for some reason excel files are not being displayed.  Files with extension .xls open with encoded text and .xlsx files prompt users to open a zip file. Any suggestions to what is going wrong here. I've microsoft excel installed at the system from which i was using the app.
Thanks
Robbe Morris replied to Pranay on 12-Feb-13 06:06 PM
Post your code.  You need to set the ContentType attribute of the Response object prior to writing file to the Response stream.
Response.Clear();
Response.Buffer = true;
Response.StatusCode = 200;
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile("C:\rob.xls");

 
help
Response.ContentType = "application / vnd.ms-excel" IGNORED! .NET Framework I have an application that worked well on IIS6. I moved it to IIS7, and response.contenttype is now ignored. my code ends with: Response.ContentType = "application / vnd.ms-excel" Response.Flush() Response.End() But the browser receives "application / octet
Hi, I am using the following code to send ASP to Excel Response.ContentType = "application / vnd.ms-excel" I have a set of 18 numbers, but once it hits 15 characters, anything after is showing as: 850036701888998000 Any thoughts would be greatly appreciated! Thank you!!!!!!!!!! IIS ASP Discussions Excel (1) Response.ContentType (1) Database (1) Resembles (1) Export the resulting excel file to html
have a webapplication with export to excel Page.Response.ContentType = "application / vnd.ms-excel"; i have added Response.AddHeader("content-disposition", "attachment; filename = " + filename+."xls"); so that u culd with the line Response.AddHeader("content-disposition", "attachment; filename = " + filename+." xls "); it works fine with excel 2003 but with 2007 after exporting the file i need to again open the exported
I have an ASP page which uses Response.ContentType = "application / vnd.ms-excel" to stream data to the client in Excel format. This seems to work, but in some browsers (IE, Netscape) it opens a new
Hi!, I'm using Response.ContentType = "application / vnd.ms-excel" to show an html table over excel sheet and I need to change the excelsheet title, does anyone know how to do AddHeader "Content-Disposition", "filename = myname.xls" keywords: ContentType, Excelsheet, Title description: Hi!, I'm using Response.ContentType = application / vnd.ms-excel to show an html table over excel sheet and I need
i use Response.ContentType = "application / vnd.ms-excel" but what i found is when the data convert to excel some data is missing like example employee ID is 0004 but in excel is 4 only. why????? why????? please help me. . thanks. . . If you manually type 004 directly
Currently I am using the: Response.ContentType = "application / vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment; filename = "myFile.xls" Opening this page will prompt the user will be. But you must have it there so it will load the data in excel format. I couldnt get the code to work without it. Dim objSXH, objADOStream Set objSXH Type = 1 ' binary Else oStream.Type = 1 ' binary oStream.Open oStream.LoadFromFile sFilePath End If Response.ContentType = "application / vnd.ms-excel" Response.AddHeader "Content-Disposition", "filename = myFile.xls" Response.BinaryWrite oStream
i am exporting frm asp.net to excel i have string filename = drpitems.SelectedItem.Text + ."xls"; Page.Response.ContentType = "application / vnd.ms-excel"; Response.AddHeader("content-disposition", "attachment; filename = " + filename); it works fine it the system frm where its exported has excel 2003 if not i am not able to export it as excel sheet so depending
I am trying to export datagrid to excel using a button_click by setting the response.contenttype = excel. . .blah blah. . . . Now the interesting thing is the dialog box to open / sava / cancel shows up but not the excel sheet. . . . Status bar says downloading page and then it suddenly displays nothing but the blank MIME settings on the webserver. . . Hi Bharath, Try using the following as your content type: Response.ContentType = "Application / x-msexcel"; Hope this helps. Back to the same situation, , , Hi Bharath, Here's
NET site, I am rendering a GridView control to export it's details in a excel file Response . ContentType = "application / vnd.ms-excel" Response . AppendHeader ( "Content-Type" , "application / vnd.ms-excel" ) Dim stringWrite As System . IO . StringWriter = New System . IO . StringWriter Dim htmlWrite As System