469,317 Members | 1,985 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,317 developers. It's quick & easy.

ASP Excel spreadsheet generation frustration

Hi all,

I'm trying to generate a simple Excel spreadsheet via ASP but I'm running in to trouble. Here's the code:

<%
response.AddHeader "Content-disposition", "attachment; filename=test.xls"
response.AddHeader "Content-type:", "excel/ms-excel; name=test.xls"
%>
<table>
<tr><td>01234</td><td>abcde</td></tr>
<tr><td>01234</td><td>abcde</td></tr>
</table>

Problem 1: I'm getting an intermittent error when loading the page:
"Internet Explorer cannot download exceltest.asp from <myservername>.
Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found." I get this prob. very 1 in 3 loads and I've scoured the net without a solid answer...

Problem 2: Excel cells default to the Generic format which means that the string "01234" above gets converted to a number and drops the leading zero. ie. "01234" becomes 1234. Is there a way around this ??

Any help would be appreciated as I've spent hours on this already...

cheers,
Matt.

--
Matt Pegg
tDC - Ballarat, Australia
email: xxxx@xxxxxxxx.xxx
Apr 18 '07 #1
3 2186
jhardman
3,406 Expert 2GB
Hi all,

I'm trying to generate a simple Excel spreadsheet via ASP but I'm running in to trouble. Here's the code:

<%
response.AddHeader "Content-disposition", "attachment; filename=test.xls"
response.AddHeader "Content-type:", "excel/ms-excel; name=test.xls"
%>
<table>
<tr><td>01234</td><td>abcde</td></tr>
<tr><td>01234</td><td>abcde</td></tr>
</table>

Problem 1: I'm getting an intermittent error when loading the page:
"Internet Explorer cannot download exceltest.asp from <myservername>.
Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found." I get this prob. very 1 in 3 loads and I've scoured the net without a solid answer...

Problem 2: Excel cells default to the Generic format which means that the string "01234" above gets converted to a number and drops the leading zero. ie. "01234" becomes 1234. Is there a way around this ??

Any help would be appreciated as I've spent hours on this already...

cheers,
Matt.

--
Matt Pegg
tDC - Ballarat, Australia
The second question is easier. Excel uses a single quote mark (apostrophe) to begin strings. Add a single quote to the beginning of all strings saved and they will never be converted to anything else. I don't know if that will cause a prob;em for you when you use the data, but it will definitely not display different on the excel file.

I'm not sure about the first question. Is this hosted locally or remotely? It is possible this is just caused by the server communicating with excel. Do you leave excel running or shut it down?

Jared
Apr 18 '07 #2
jhardman
3,406 Expert 2GB
By the way, it is a good idea to hide your email address. Other TSDN members can send you personal messages regardless, and posting your email may leave you open to spammers.

Jared
Apr 18 '07 #3
Does anyone have a solution to Problem 1 above? I'm running into that issue and I don't see any solutions anywhere.
Dec 20 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Phil Powell | last post: by
3 posts views Thread by toffee | last post: by
3 posts views Thread by S_K | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.