![]() |
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 |
display long number as text
oSheet.Cells(rowNum, i + 1) = "'" & dr.GetValue(i).ToString
The single quote will make it a string and will not display. -- Regards, Tom Ogilvy "Daisy" wrote in message ... 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 |
display long number as text
It works. Thanks a lot!
"Tom Ogilvy" wrote: oSheet.Cells(rowNum, i + 1) = "'" & dr.GetValue(i).ToString The single quote will make it a string and will not display. -- Regards, Tom Ogilvy "Daisy" wrote in message ... 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 |
All times are GMT +1. The time now is 02:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com