Excel Export is opening in .aspx file instead of .xls file

I am facing one problem. I am using Visual Studio .NET 2003. I made a project to export datagrid into excel file. I wrote the code and when I excute it it opens in .aspx file and name of the file is same as the file in which I wrote this code. This happens when I run the application from my machine and code is deployed on different server.

Please help.

Code which I am using is

Response.Buffer = True
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
lstrReportNameXls = "Reports.xls"
Me.EnableViewState = False
Response.AddHeader("content-disposition", "attachment; filename=" + lstrReportNameXls + "")

Dim oStringWriter As System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter
oStringWriter = New System.IO.StringWriter
oHtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)



7/13/2006 5:03:49 PM
asp.net.vs2002-vs2003 3502 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 40


Similar Artilces:

When export file in safari it gets downloaded as .aspx file instead of .xls ..Dont know why
Hi .. I have written a code to export a file as..Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel";Response.Charset = ""; Response.AddHeader("content-disposition", "attachment;filename=Ma_Report_" +Session["man"]+ ".xls"); //EnableViewState = false;System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);oHtmlTextWriter.Write("<br>"); oHtmlTextWriter.Write("<B>&q...

When export file in safari it gets downloaded as .aspx file instead of .xls ..Dont know why #2
My Code is as below Private Sub GenerateReport(ByVal dt As DataTable, ByVal fileName As String)        Try            If dt.Rows.Count > 0 Then                grdReport.DataSource = dt                grdReport.DataBind()                Response.Clear()    &nbs...

Got error after open excel file from server..During Export Excel File
this error appears if you have tried to save a workbook on a drive and you do not have Modify and Delete permissions to the location where the file is being saved. It is also possible that another user has a read lock on the file.Excel saves a file using three steps (if the file already exists in the target location):Creates a temporary file with a randomly generated name, such as 4CCA4100.Deletes the original file.Renames the temporary file to the original file name.If Excel cannot delete the original file or cannot rename the temporary file, this error message appears.To temporarily work a...

could not open project and all .cs files, .aspx.cs files and .csproj file
All my projects could not open after one night. Error is like the following:The application for project 'http://localhost/WebApplication1/WebApplication1.csproj is not installed. Make sure the appliction for the project type(.csproj) is installedAnd when I check these files, all .cs files, .aspx.cs files and .csproj file's icon become notepad, could only open as a text file.Can I get any sugestion from here? Thanks a lot....

File open dialog box opens when I click on aspx files
Hi allI have all my aspx files on a server. But, when I click on them, the File open dialog box opens instead. FYI, I have deleted the debug=true line from the config file.Can someone help me with this? You can't click on ASPX files and have them processed, they have to be requested by URL through a server configured to process ASP.NET. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue....

Why when Export datagrid to excel to exp.xls I get a web file when I open it ?
Hi , I have a method that export datagrid to excel. the file I get is with the correct data but the problem is that when trying to upload it and open it again I get format exception.  That exception solved if when I have the file on my desktop I Save As.. it as Microsoft Office Excel Workbook. It seems that it was a Web Page before. Is there a header line that I need to add or something else ? My code is: this.Response.Clear(); this.Response.AddHeader("content-disposition", "attachment;filename=" + fileName); this.Response.Charset = ""; this.Response.Cache.SetCacheability(Ht...

Excel Export => file type of exported *.xls
Hello, When i export a Excel sheet from an datasource with the code that is provided in multiple posts on this forum the output is correct.But, when i import the excelsheet into a Microsoft Access *.mdb with VBA (DoCmd.TransferSpreadsheet) it returns an error that the external table is not in the expected format. When i check the internal filetype of the exported file it is an 'acHTML'. After a Save As *.xml it is a normal Excel file and the import into the Microsoft Access *.mdb went successful. Can someone give a workaround or solution? RamR0m   Sorry, i meant: "When i check t...

How to export the output of an aspx file to pdf file?
 Hi everyone;I have a .net application that generates a report. I would like to create an option for users to save their output in a pdf file and record it on their computer.I'm wondering if you have any idea about the code? I am using C# and I didn't user crystal report.Thank you in advance. Hi Friend, Try to use the following link.  http://csharpdotnetfreak.blogspot.com/2008/12/export-gridview-to-pdf-using-itextsharp.htmlEnjoy Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solv...

Error while opening an excel file : file could not be found
Hi All,   I am using the below code to export data from datagrid to excel.     dtgDailyReports.AllowSorting = false;                         DataSet ds = new DataSet();                         ds = (DataSet)ViewState["DailyReport"];                  ...

Open File Dialog and browse for file in aspx?
Hello everyone, Can someone show me the right way to open the file dialog and browse for a file in local directory?  In window application, I can use the function calls "OpenFileDialog" to open the file dialog and get the filename but can't use it in the web, it doesn't recognize the "OpenFileDialog" and the error message I have was "The type or namespace name 'OpenFileDialog' could not be found (are you missing a using directive or an assembly reference?)".  Can someone show me the right way to replace those two button below for the w...

Help me export .xls file to SAS file.
Dear All  Please help me how to export XML to SAS in C# codeing, Also .xls file to SAS file. Thanking you, saikat...

How to include an aspx-file in an aspx-file?
Hello, I have an ASP.NET page ("Kalender.aspx") where I would like to include another ASP.NET page ("MyCalendar.aspx"), so far I couldn't find the solution... 8{ This is the code of "Kalender.aspx" : ------------------------------------------------------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>zjaak</title> </head> <body> <table height="377" cellspacing="0" cellp...

How to convert excel file to csv file(.xls to .csv)?
Hi, Anybody know how to convert excel file to csv file? Appreciate so much to your kindly reply. ~p@ywen~ nothing is impossible ^_^v few ways to do it. I'd say go after it with ado.net, and load it into a datatable. but if you want to use the office interop, d/l from microsoft.com, and play with it. remember that it's easier to work with vb when it comes to office. at least until whidbey comes out.Kay LeeMySpace.com - http://www.myspace.com/kragieInfrastructure GroupMySpace.com- Code to live, but Live to code....

Codes to open WordTemplate files from a subfolder in an ASPX file
 I have WordTemplate folders and files in an ASPX file.  The WordTemplate files underthe Intranet folder directly have no problems to be opened.  However the files in the subfoldercan not.     With a msgbox, the href link seemed to be correct. Following are the codes from my Web form aspx file and VBScript classic asp file. Why the Word doc/dot files can not be opened?  TIA,Jeffrey *********************************************** Response.write line in my Forms.aspx: Response.Write("<a href='#' onClick=""w...

Web resources about - Excel Export is opening in .aspx file instead of .xls file - asp.net.vs2002-vs2003

Encyclopaedia of Chess Openings - Wikipedia, the free encyclopedia
The Encyclopaedia of Chess Openings (or ECO ) is a classification system for the opening moves in a game of chess . It is presented as a five-volume ...

INFOGRAPHIC: Major League Baseball Facebook Standings At Opening Of 2013 Season
The New York Yankees may be injury-plagued and off to a sluggish start to the 2013 Major League Baseball season, but when it comes to Facebook ...

Apple now opening four new Apple Stores in China this month alone, as it announces #31 and #32
... in China by October as it has announced that two more stores will open this month. That will bring the total in China to 32, four of them opening ...

'Star Wars' Sales Top $50 Million in China Opening Weekend
Walt Disney said "Star Wars: The Force Awakens" generated $53 million at the box office during its opening weekend in China, adding to the success ...

Fox reveals the opening scene of the new ‘X-Files’ series
We’ve already seen footage from the new X-Files TV series that is due to premiere on January 24th, but we can now watch the show's first scene ...

Rostam releases solo song; PWR BTTM opening for Ra Ra Riot
by Tatiana Tenreyro photo: Vampire Weekend at Governors Ball 2014 (more by Amanda Hatfield Rostam Batmanglij of Vampire Weekend has released ...

BLS: Jobs Openings increased in November
From the BLS: Job Openings and Labor Turnover Summary The number of job openings was little changed at 5.4 million on the last business day ...

Ricky Gervais Opening At Golden Globes – “I’m Getting Exactly The Same As Tina And Amy”
Hosting the Golden Globes for the fourth time, the first since 2012, Ricky Gervais had a small sackful of barbs, several aimed at Jennifer Lawrence ...

Nitehawk-Like Movie Theater With Restaurant Opening in Bushwick Today
... oyster dish during the film. A movie theater and restaurant — with wait service during the film in the same vein as Nitehawk Cinema — is opening ...

Resources last updated: 1/17/2016 2:21:08 PM