473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 16292
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: LRW | last post by:
This may be a question more directed to Excel, but I'm using PHP to generate a CSV to be imported into Excel, so maybe the solution is there. So, sorry for crossposting. Anyway, I'm generating a...
1
by: Jawahar Rajan | last post by:
All, I am using the ASP code below to save some data from a SQL Server database via ADO as an Excel spreadsheet strReportName = Request.QueryString("ReportName") If len(strReportName) > 0 then...
5
by: Tlm | last post by:
Hello All, I'm importing Contact data from a Excel spreadsheet into an Access table. No problem there. However, here in Massachusetts our zip codes start with 0 and the spreadsheet omits it. ...
1
by: mmmgood1 | last post by:
Help, I'm linking an excel spreadsheet in access and I have datafields with leading zeros (01021). When the file is linked in access, I get a #num in the field with the leading zeros. The zeros...
6
by: Kevin Humphreys | last post by:
Hi There, I am trying to export a recordset to an excel file using the Content Type below in the header. Response.ContentType = "application/vnd.ms-excel" Which works fine however the...
3
by: Matt Pegg | last post by:
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;...
6
by: JimmyKoolPantz | last post by:
Task: Customer wants a script of the data that was processed in a "CSV" file. Problem: Zip-Code leading zeros are dropped Basically we have a client that has requested a custom script for...
5
by: Reggie | last post by:
Hi and TIA! I have an export procedure that exports my data from my datagrids to excel. The problem is that I lose leading zero's cause excel removes them and doesn't treat them as text. Is it...
7
benchpolo
by: benchpolo | last post by:
I have an excel spreadsheet (.csv) format of list of zipcodes that I am trying to import to my custom table zipcodes.. I having issue in importing a zip code with leading zero. Can someone assist me...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.