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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel File and Formating Data Cells

Status
Not open for further replies.

TWillard

Programmer
Apr 26, 2001
263
US
I am using ASP/VBScript to build an excel file. The data populating the excel file comes from a query executed against a database. I am trying to format the cells of the excel worksheet.

Specifically, I need my data to be treated as text. The numbers that I am trying to display are contract, bol, po, and order numbers. Therefore, I need to show the numbers exactly as they are stored in the database and on the customers' statment.

I am having the following problems:

Data Excel
------- -----
0000123 123 >> Drops the starting zeros
123456789012345 1.23457E+14 >> Changes to sci. notation


FAILURE 1:
-----------
I have read Microsoft's Excel Web Connectivity Kit and I have tried using the following in my <TD> cell.

STYLE=&quot;vnd.ms-excel.numberformat:###############&quot;

This will handle large numbers. However, it still will drop the leading zeros.


FAILURE 2:
-----------
I have also tried using excel's function directly in my cell.

=CLEAN(000012345)

Again, this will handle large numbers, but it will drop off the leading zeros.


Does anyone have any suggestions or solutions? I am drowning here, please help. Thank You.
 
I think I may have found a soltion to my problem:

FYI....

STYLE=&quot;vnd.ms-excel.numberformat:00000000000000&quot;

This line of code is different than the code I have posted above. As you can see I am formating with zeros and not the pound sign. The # will treat the number as an exact number, and therefore leading zeros will be dropped. This given format will show leading and trailing zeros. It will handle large numbers that would otherwise be converted into scientific notation. It will also show alphnumeric data correctly.
 
STYLE=&quot;vnd.ms-excel.numberformat:mad:&quot;

This will turn an excel cell into type text. This is the solution that I am implementing for my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top