VB.net and Ecxel column format
I pull data from an Oracle table and loop through to fill an array.
I then transfer the array into an excel sheet.
2 columns are supposed to be numbers, but are "saved" on the excel sheet as text. Clicking on the little green corner states "Saved as Text".
conditioning the data prior to entering it into the array:
Code:
CDbl(rstNumQCRs("PERCENTAGE").Value)
Then setting the column format:
Code:
.Columns.range("H2:H100").NumberFormat = "0.00"
Entering the data in the sheet:
Code:
.Range(.Cells(2, 1), .Cells(r + 1, 8)).Value = arData
Setting the format before or after does not alter the data, it is still saved as text.
The top row contains the col titles, could this be the cause?
Re: VB.net and Ecxel column format
try something like this:
Code:
ActiveSheet.Range("H1").EntireColumn.NumberFormat = "@"
Re: VB.net and Ecxel column format
I added the line after I dropped the data on the spreadsheet.. No change
I changed the range to "H2" to allow for the col headers and no change.
I changed the format to "0.0" and again no change.
This should be working.... Aarrgghh...
Re: VB.net and Ecxel column format
Got it.
Code:
oXL.xlSheet.Range("E6:J100").Value = oXL.xlSheet.Range("E6:J100").Value
Weird but true....
Re: VB.net and Ecxel column format
vb.net does have some interesting quirky behaviour occasionally...