View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Daisy[_4_] Daisy[_4_] is offline
external usenet poster
 
Posts: 2
Default display long number as text

I have a very long number (16 digits). How can I display it as text so that
it would not be truncated as 1.18621E+16 in the cell while the cell has been
set to autofit format? It also might be a general question simply display
data as text in each cell?

I am using XP pro/Visual studio 2003/Office 2003. Part of the code is as
following. Thanks!


Try
If dr.FieldCount Then
While dr.Read()

For i = 0 To dr.FieldCount - 1

'write to excel
oSheet.Cells(rowNum, i + 1) = dr.GetValue(i).ToString

'write to text file
strLine2 = strLine2 & dr.GetValue(i).ToString & ","
Next
rowNum += 1

objStreamWriter2.WriteLine(strLine2)
strLine2 = ""
End While

For i = 1 To dr.FieldCount - 1
'write to excel
oSheet.Cells(rowNum, i + 1).EntireColumn.Autofit()
oSheet.Cells(rowNum, i + 1).autofilter()
Next


End If
Catch ex As Exception
Console.WriteLine(ex.Message.ToString)
End Try