?
Solved

How to give an Excel file a file name when exporting a GridView to Excel 2003 when using ASP.NET 4.0 with C# and VS2010 ?

Posted on 2013-12-09
3
Medium Priority
?
576 Views
Last Modified: 2013-12-10
I'm writing my first ASP.NET 4.0 application using C# with VS2010.

I am trying to export a stored procedure result set to Excel 2003.

When I create the new Excel file, I noticed that it is named DEFAULT.XLS.

DEFAULT is the name of the web page.

Do you know how I can modify my code to assign the newly created Excel file the file name Contacts.XLS rather than Default.XLS?

My code is in the attached file:
ASP-CODE.txt
0
Comment
Question by:zimmer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 39707615
1/ you are not writing a file, just output to the webbrowser that you tell it to interpret as an excel file

2/ Excel is smart/dumb enough to accept a textfile as input

3/ Default is the name of any new excel workbook i believe. When you press save.
0
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 2000 total points
ID: 39707884
Change

 Response.AddHeader("contenet-disposition", attachment);

Open in new window


to

 Response.AddHeader("content-disposition", attachment);

Open in new window

0
 

Author Closing Comment

by:zimmer9
ID: 39708418
Excellent catch!!!
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question