Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula to display just number and not text | Excel Discussion (Misc queries) | |||
Display only n numbers of characters for long text? | Excel Worksheet Functions | |||
How do I display number into form of text or word? | Excel Worksheet Functions | |||
"formula is too long" AND test for whether double-quotes are next-to text or number?? | Excel Discussion (Misc queries) | |||
how to display number(10) to text(ten) | Excel Discussion (Misc queries) |