473,836 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Conten tType = "applicatio n/vnd.ms-excel"
Response.Charse t = ""
this.EnableView State = false
//Response.AddHea der("Content-Disposition", "filename=Data. xls;"); // set the filenam
Response.Write( "something" )

Response.End()

I tried to set the filename by Response.AddHea der. 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 2522
Hmmm ... Shouldn't you be including "attachment " in there? Don't forget to
clear the preceding content:

Response.Clear( );
Response.ClearH eaders();
Response.ClearC ontent();
Response.Buffer = true;
Response.Conten tType = "Applicatio n/x-msexcel";
Response.Append Header("content-disposition", "attachment ;
filename=Data.x ls" );

"zweng" <zu*******@us.b osch.com> wrote in message
news:89******** *************** ***********@mic rosoft.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.Conten tType = "applicatio n/vnd.ms-excel";
Response.Charse t = "";
this.EnableView State = false;
//Response.AddHea der("Content-Disposition", "filename=Data. xls;"); //
set the filename
Response.Write( "something" );

Response.End();

I tried to set the filename by Response.AddHea der. 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.b osch.com> wrote in message
news:E3******** *************** ***********@mic rosoft.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
2383
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 script is that I'm migrating several dozen Mac users to PCs over the next few months and many of the Mac files do not have PC filename extensions. There are thousands of these files. The script runs on a Linux ftp server where the files are...
1
4343
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 = "application/vnd.ms-excel" .Write(strResponse) .Flush .End End With
3
270
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 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 ...
6
2631
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 each of the Excel file names as they are exported. It seems that the OutputTo action only allows for predetermined names or a prompt for each file. I do not want to type the file names 70+ times and renaming each of the ..xls files afterwards is a...
2
11004
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 "Save As" dialog and the ability to grab the filepath so that the second export appends to it. Anyway, I found Microsofts method and it works, except that I can't figure out how to populate the File Name box in the Dialog with a default name (say,...
6
4033
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, there is some portion of the data which has gotten out of order when I look into the text file, the ID shows this. How do I stop this happening? Regs
0
1460
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 found (http:// www.codeproject.com/csharp/Excel_DataReader.asp) but this also threw an error trying to read the header. I believe that this is all happening because the exported Excel file is in some sort of html table format. Does anyone know...
1
3064
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 not export line excelsheet.Cells(9, 2) = rsschedulesrecords.Fields(2).Value. Below is my code. Please help? Private Sub CreateDailyRoster(rsschedulesrecords As DAO.Recordset) Dim excelapp As New Excel.Application Dim excelfile As...
3
4364
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 now the way I have this set up, but it's confusing and slow. When they browse for a place to save the reports, they see all of the drives on the terminal server as well as their own client drives. So they're likely to want to choose "My...
1
1649
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 given by a serial number (date format). Here is my data 067-02 067-01 196-00 196-00 appears correctly but 067-02 and 067-01 are converted to a serial date number. Is there any way to prevent this from happening? Another report generated...
0
9658
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10824
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10579
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10244
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7775
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6975
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.