469,356 Members | 2,168 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

leading zero's for excel content

Hi
I use reponse.contenttype = "application/vnd.ms-excel"
So the browser will show the data in excel format, but for
some fields I use leading zero's, which truncated by the
browser, at this content type.
If I concat a "'", or other none numeric char, the problem
is solved inconsistently!!!
But even this solution is problematic - is there any
solutions, explanation?

Jul 19 '05 #1
3 16055
If Excel sees a number, it's going to drop leading zeros, because they're
meaningless. If you are trying to represent a number as a string, then
treat it as a string (prefix with ' )... why is this problem "solved
inconsistently" or "problematic"?

"yanir" <ya*****@hotmail.com> wrote in message
news:04****************************@phx.gbl...
Hi
I use reponse.contenttype = "application/vnd.ms-excel"
So the browser will show the data in excel format, but for
some fields I use leading zero's, which truncated by the
browser, at this content type.
If I concat a "'", or other none numeric char, the problem
is solved inconsistently!!!
But even this solution is problematic - is there any
solutions, explanation?

Jul 19 '05 #2
"yanir" wrote:

I use reponse.contenttype = "application/vnd.ms-excel"
So the browser will show the data in excel format, but for
some fields I use leading zero's, which truncated by the
browser, at this content type.
If I concat a "'", or other none numeric char, the problem
is solved inconsistently!!!
But even this solution is problematic - is there any
solutions, explanation?


One solution is to put a non-breaking space (&nbsp;) in the cell. This
instructs Excel to treat the data as text. You can also use specific style
attributes that Excel recognizes, such as mso-number-format. This example
imposes a 5-digit mask on the numeric cell contents:

<TD STYLE="mso-number-format:00000">

I have no idea where this is documented. I reverse-engineered by saving an
Excel spreadsheet as HTML and reading source code.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3
You helped me a lot, thanks
-----Original Message-----
I've found when you use the ' like this, you'll wind up seeing the ' in thecell - pretty irritating. You may be able to do:

<td>=TEXT(<%=YourNumber%>,"<%=String(Len (YourNumber), "0")%>")</td>
to produce
<td>=TEXT(0001,"0000")</td>

Ray at work

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in messagenews:eJ**************@TK2MSFTNGP10.phx.gbl...
If Excel sees a number, it's going to drop leading zeros, because they're meaningless. If you are trying to represent a number as a string, then treat it as a string (prefix with ' )... why is this problem "solved inconsistently" or "problematic"?

"yanir" <ya*****@hotmail.com> wrote in message
news:04****************************@phx.gbl...
> Hi
> I use reponse.contenttype = "application/vnd.ms-excel"
> So the browser will show the data in excel format, but for > some fields I use leading zero's, which truncated by the > browser, at this content type.
> If I concat a "'", or other none numeric char, the problem > is solved inconsistently!!!
> But even this solution is problematic - is there any
> solutions, explanation?
>


.

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by LRW | last post: by
1 post views Thread by Jawahar Rajan | last post: by
5 posts views Thread by Tlm | last post: by
1 post views Thread by mmmgood1 | last post: by
6 posts views Thread by Kevin Humphreys | last post: by
6 posts views Thread by JimmyKoolPantz | last post: by
5 posts views Thread by Reggie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.