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
473 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
3 Comments
 
LVL 32

Expert Comment

by:Robberbaron (robr)
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Excellent catch!!!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now