Results 1 to 5 of 5

Thread: VB.net and Ecxel column format

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    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?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: VB.net and Ecxel column format

    try something like this:

    Code:
    ActiveSheet.Range("H1").EntireColumn.NumberFormat = "@"

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    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...

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    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....

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: VB.net and Ecxel column format

    vb.net does have some interesting quirky behaviour occasionally...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width