How to show numbers with length > 12 in Excel

Technical support for Spire.XLS

Moderators: iceblue support, Flash, Manager

How to show numbers with length > 12 in Excel

Postby pb » Tue Jun 24, 2008 12:56 pm

I got the problem to show a 13 digit number correctly in a sheet.

Excel automatically format it into the sientific notation (1,0+E12), but i need the number to be shown complete.

What to do to format the sheet that way, that numbers are not changed to the scientific notation.?

BTW:

How can i generally set the format for a Cell or CellRange to string, even if i enter numbers?

Because sometimes you can have a numberstring e.g. for a zip code starting with a '0'. Without the correct format Excel automatically change this to a number and kills the '0'.
pb
 
Posts: 14
Joined: Fri Jun 20, 2008 11:05 am

Postby pb » Wed Jun 25, 2008 2:12 pm

Until there is a different approach i'm adding a single ' before the number, this forces Excel to handle a number as string.

Code: Select all
wb.Worksheets[sheet].Columns[x].Rows[y].Value2 = "'" + wb.Worksheets[sheet].Columns[x].Rows[y].Value2.ToString();


Not very clean, but for the moment it works.
pb
 
Posts: 14
Joined: Fri Jun 20, 2008 11:05 am

Postby Flash » Fri Jun 27, 2008 4:24 pm

Hello,

You can try to using following source code,

Code: Select all
  wb.Worksheets[sheet].Columns[x].Rows[y].NumberFormat = "@";
User avatar
Flash
 
Posts: 56
Joined: Thu Jun 29, 2006 2:34 pm

Postby pb » Mon Jun 30, 2008 7:28 am

I tried, but it doesn't work with NumberFormat = "@", it changes to the 1E+12 format. Maybe a problem from Excel.
pb
 
Posts: 14
Joined: Fri Jun 20, 2008 11:05 am

Postby pb » Wed Jul 02, 2008 1:53 pm

I'm now using NumberFormat = '0'. That way Excel shows the number as it is and no longer shortens it. (At least it do this on my system).
pb
 
Posts: 14
Joined: Fri Jun 20, 2008 11:05 am


Return to Spire.XLS

Who is online

Users browsing this forum: No registered users and 0 guests