473,394 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

filename in exported excel file

I checked a few sites on exporting data from asp.net to excel and most of them point to the same source a
http://support.microsoft.com/default...b;EN-US;317719 with some modifications

My code is in the block below. When I click save when the open/save message box pops up, the file is saved as the aspx page's name with .xls. However, when I open the file, the filename is the exact aspx page name with .aspx in MS Excel

Response.Buffer = true
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
this.EnableViewState = false
//Response.AddHeader("Content-Disposition", "filename=Data.xls;"); // set the filenam
Response.Write("something")

Response.End()

I tried to set the filename by Response.AddHeader. When I do a save, the filename is saved as the specified .xls. However, when I open the file from the open/save popup, the filename is still the aspx page's name

I am wondering what could be wrong and how to fix this

Thank you

Zud
Nov 18 '05 #1
3 2484
Hmmm ... Shouldn't you be including "attachment" in there? Don't forget to
clear the preceding content:

Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Buffer = true;
Response.ContentType = "Application/x-msexcel";
Response.AppendHeader("content-disposition", "attachment;
filename=Data.xls" );

"zweng" <zu*******@us.bosch.com> wrote in message
news:89**********************************@microsof t.com...
I checked a few sites on exporting data from asp.net to excel and most of
them point to the same source at
http://support.microsoft.com/default...b;EN-US;317719 with some
modifications.

My code is in the block below. When I click save when the open/save
message box pops up, the file is saved as the aspx page's name with .xls.
However, when I open the file, the filename is the exact aspx page name
with .aspx in MS Excel.

Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
//Response.AddHeader("Content-Disposition", "filename=Data.xls;"); //
set the filename
Response.Write("something");

Response.End();

I tried to set the filename by Response.AddHeader. When I do a save, the
filename is saved as the specified .xls. However, when I open the file
from the open/save popup, the filename is still the aspx page's name.

I am wondering what could be wrong and how to fix this.

Thank you.

Zude


Nov 18 '05 #2
Hi, Ken

"attachment" kind of worked. For all the additions you relied, only the "attachment" made the opened excel file has the data[1].xls.

However, I need to click the Open button twice to open it when the open/save message box popped up and I think this is because it was attaching the first time I clicked and the second click opened it up

Are there any other attributes or properties need to be set to open the file by only clicking one

Thank you

Zude
Nov 18 '05 #3

This business about having to click Open twice is a bug in IE; the only way around it that I know,
involves changing/creating a new page with the appropriate file name extension and avoiding the
attachment option.

There was a thread about the a week or so ago.

Scott

"zweng" <zu*******@us.bosch.com> wrote in message
news:E3**********************************@microsof t.com...
Hi, Ken,

"attachment" kind of worked. For all the additions you relied, only the "attachment" made the opened excel file has the data[1].xls.
However, I need to click the Open button twice to open it when the open/save message box popped up and I think this is because it was attaching the first time I clicked and the second click opened it
up.
Are there any other attributes or properties need to be set to open the file by only clicking one?

Thank you.

Zude

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: hokiegal99 | last post by:
I've written a small script (with much help from this list) that searches through a directory for files without a PC filename extension like .doc .xls and then adds them. The reason for writing the...
1
by: SW | last post by:
I have an ASP page that causes Excel to be loaded on the client PC with the text sent from within the page. An excerpt of it is shown below: With Response .ContentType =...
3
by: zweng | last post by:
I checked a few sites on exporting data from asp.net to excel and most of them point to the same source a http://support.microsoft.com/default.aspx?scid=kb;EN-US;317719 with some modifications My...
6
by: ninrulz | last post by:
I have created a database that has over 70 queries and over 40k records. I used the OutputTo action to export the queries to Excel. I would like the functionality of adding the date (Month-YY) to...
2
by: vbaDev | last post by:
Hi. I am using Access 2000 and in my code I'm exporting a table into an Excel file (creating it), then the code needs to export another query into the same file (a new worksheet). So I needed both a...
6
by: La di da Limey | last post by:
Hi, I have a simple database. It has 3 columns of data and an ID so that I can sort it into it original order. After having sorted it, I export it as a text file. Yet every time I export it,...
0
by: mohaaron | last post by:
I am finding that when a GridView is export to Excel by changing the ContentType of the page the Excel file is not readable by OleDb or SQL Server DTS. I also tried using a Excel Reader that I...
1
by: accessvbanewbie | last post by:
I would like to export a recordset from access to excel but after each record is exported I want to insert a new row. The first recordset does this ok. However, the second recordset onwards does not...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
1
by: brent78 | last post by:
I'm trying to export an access report to excel and have run into a problem. One of my fields is a text field and when it is exported to excel some of the data values show up correctly and some are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.