Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting to excel

Status
Not open for further replies.

ladyck3

Technical User
Jan 3, 2003
800
US
Hi, I've had no problems using the information below to export data to an excel workbook, but its not working on the server that hosts my website. I can test it all day long on "localhost" but it won't work on my site.

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=DB_Search_Results.xls"


Is it a problem, do you think, exporting to Excel? I guess not everyone may have excel so I'm thinking of exporting to a CSV file, that way folks can hande it at their choosing.

I did not write this, I had help from a coworker.... I'm wondering how to edit this to (because I am not a programmer) export to a csv file.

I tried changing vnd.ms-excel to vnd.ms-notepad and renaming the exported file to .txt and .csv but I get the same 500 error on my site.

Otherwise is it a permissions with my hosting folks? Is thi something that normally is not permitted on a server? I had the DB password protected but removed the password thinking that might be the problem but nope....that wasn't it either.

I've been playing with this for over 14 hours now... I've fought the good fight... HELP!!!

Laurie


LadyCK3
aka: Laurie :)
 
Hi Laurie,

I'm no expert when it comes to these things but below is what I use to export info from a web page to excel

Code:
<%
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "filename=[b][COLOR=red]YourFileName.xls[/color][/b];"
%>

As you will see I do not have this code in mine

Code:
"attachment;
Not sure if this would make a differnce but it might, when our users export they are asked if they want to open the file or save it, does yours do the same when using on "localhost" ?

Regards

Paul

 
You mentioned wanting a csv file, so here it is:

Code:
<%
Response.ContentType = "text/csv"
Response.AddHeader "Content-Disposition", "filename=YourFileName.csv;"
%>

As long as the HTTP headers are set correctly then the binary output (as Response.Write) will prompt the Save AS dialog.
 
Hi,

Pls i have the same problem with exporting data to excel. the problem I have is that text data overflows to another cell there by pushing the data thats suppose to be on the next cell to a new row. Also in a text data with comma, the comma moves the following words/sentence to the next cell.

Pls how can I control the placement of data in the right cell.
 
Candyman,

Thanks very much for your response, I will save the code for exporting to a CSV file, its GREATLY appreciated.

My export works, but the problem I have with my search is the customary wild card % search is not working, something about a 4Mb limit? The DB is 2.5Mb, the exported XLS (from the db) is 1MB, so how does a search for all records end up going over 4mb?

When I try the search, in IE7 I get an HTTP500 error but my server provider tried it in FireFox which showed the following error:
-----------------------------

Response object error 'ASP 0251 : 80004005'

Response Buffer Limit Exceeded

/data/new_wb_lookup.asp, line 0

Execution of the ASP page caused the Response Buffer to exceed its configured limit.
--------------------------------------

So I asked my hosting service who found this error, how can I/We fix this.... and did not get a response.

Any ideas?

thanks...

Laurie


LadyCK3
aka: Laurie :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top