?
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
?
605 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)
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

809 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