Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 07:32 AM
yanir
Guest
 
Posts: n/a
Default 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?

  #2  
Old July 19th, 2005, 07:32 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: leading zero's for excel content

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" <yanir_r@hotmail.com> wrote in message
news:040c01c36005$f5cc8470$a001280a@phx.gbl...[color=blue]
> 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?
>[/color]


  #3  
Old July 19th, 2005, 07:32 AM
Dave Anderson
Guest
 
Posts: n/a
Default Re: leading zero's for excel content

"yanir" wrote:[color=blue]
>
> 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?[/color]

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.


  #4  
Old July 19th, 2005, 07:32 AM
yanir
Guest
 
Posts: n/a
Default Re: leading zero's for excel content

You helped me a lot, thanks[color=blue]
>-----Original Message-----
>I've found when you use the ' like this, you'll wind up[/color]
seeing the ' in the[color=blue]
>cell - pretty irritating. You may be able to do:
>
><td>=TEXT(<%=YourNumber%>,"<%=String(Len[/color]
(YourNumber), "0")%>")</td>[color=blue]
>
>to produce
><td>=TEXT(0001,"0000")</td>
>
>Ray at work
>
>"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in[/color]
message[color=blue]
>news:eJSAOHBYDHA.2020@TK2MSFTNGP10.phx.gbl...[color=green]
>> If Excel sees a number, it's going to drop leading[/color][/color]
zeros, because they're[color=blue][color=green]
>> meaningless. If you are trying to represent a number[/color][/color]
as a string, then[color=blue][color=green]
>> treat it as a string (prefix with ' )... why is this[/color][/color]
problem "solved[color=blue][color=green]
>> inconsistently" or "problematic"?
>>
>>
>>
>>
>>
>> "yanir" <yanir_r@hotmail.com> wrote in message
>> news:040c01c36005$f5cc8470$a001280a@phx.gbl...[color=darkred]
>> > Hi
>> > I use reponse.contenttype = "application/vnd.ms-excel"
>> > So the browser will show the data in excel format,[/color][/color][/color]
but for[color=blue][color=green][color=darkred]
>> > some fields I use leading zero's, which truncated by[/color][/color][/color]
the[color=blue][color=green][color=darkred]
>> > browser, at this content type.
>> > If I concat a "'", or other none numeric char, the[/color][/color][/color]
problem[color=blue][color=green][color=darkred]
>> > is solved inconsistently!!!
>> > But even this solution is problematic - is there any
>> > solutions, explanation?
>> >[/color]
>>
>>[/color]
>
>
>.
>[/color]
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles