+ Reply to Thread
Results 1 to 2 of 2

A Ruby/Excel issue - Cross posted from Miscellaneous

  1. #1
    Registered User
    Join Date
    08-02-2006
    Posts
    2

    A Ruby/Excel issue - Cross posted from Miscellaneous

    All, apologies for the cross posting, but I had no takers on the Miscellaneous forum.

    I don't think this is pecifcally a Ruby problem, that's just what I was using when I encountered the issue below.

    I am having a troublesome problem. I am trying to pull data out of a complex Excel workbook (several worksheets in the book) and make the contents available for a variety of reporting uses. I am working in Ruby - for no reason other than "just because".

    All is going well when I have cells that contain simple data types, but as soon as there is any kind of complexity in a formula, I get a weird negative number back instead of the contents. For example:

    Cell K3 has this formula.....=VLOOKUP(H3,Quadrant_Table,3)
    The value when that formula is executed is "Adopt" and that is what shows on the screen.
    When I go in from Ruby (via WIN32OLE), I get the number -2146826265 back.

    The Ruby snippet that does this is

    colIndex = @startCol
    colIndex.upto(endCol) {|aCol|
    currCell = ("#{@@colnames[aCol-1]}#{aRow}")
    @cells << (sheet.Range(currCell) ['Value']).to_s

    }
    }
    end

    @cells is an array of individual cells. There are likely to be many better (faster) ways of getting the range back in one fell swoop, but right now I am less interested in that. First get answers that you like, then improve the approacch!

    For simple string values, non formula arithmetic values, this delivers just what it should. However for these complex formulae the result is always that funky -2146826265. This is also x'800A07E7' which looks suspiciously like an hresult value.

    So the question is, how to I get the displayed value out of the cell from my Ruby program?

    Thanks in advance for any help.

    Chris

  2. #2
    Tom Ogilvy
    Guest

    Re: A Ruby/Excel issue - Cross posted from Miscellaneous

    Errors

    Maybe something here:

    http://support.microsoft.com/kb/186063/en-us
    INFO: Translating Automation Errors for VB/VBA (Long)

    --
    Regards,
    Tom Ogilvy

    "seabird20" <[email protected]> wrote
    in message news:[email protected]...
    >
    > All, apologies for the cross posting, but I had no takers on the
    > Miscellaneous forum.
    >
    > I don't think this is pecifcally a Ruby problem, that's just what I was
    > using when I encountered the issue below.
    >
    > I am having a troublesome problem. I am trying to pull data out of a
    > complex Excel workbook (several worksheets in the book) and make the
    > contents available for a variety of reporting uses. I am working in
    > Ruby - for no reason other than "just because".
    >
    > All is going well when I have cells that contain simple data types, but
    > as soon as there is any kind of complexity in a formula, I get a weird
    > negative number back instead of the contents. For example:
    >
    > Cell K3 has this formula.....=VLOOKUP(H3,Quadrant_Table,3)
    > The value when that formula is executed is "Adopt" and that is what
    > shows on the screen.
    > When I go in from Ruby (via WIN32OLE), I get the number -2146826265
    > back.
    >
    > The Ruby snippet that does this is
    >
    > colIndex = @startCol
    > colIndex.upto(endCol) {|aCol|
    > currCell = ("#{@@colnames[aCol-1]}#{aRow}")
    > @cells << (sheet.Range(currCell) ['Value']).to_s
    >
    > }
    > }
    > end
    >
    > @cells is an array of individual cells. There are likely to be many
    > better (faster) ways of getting the range back in one fell swoop, but
    > right now I am less interested in that. First get answers that you
    > like, then improve the approacch!
    >
    > For simple string values, non formula arithmetic values, this delivers
    > just what it should. However for these complex formulae the result is
    > always that funky -2146826265. This is also x'800A07E7' which looks
    > suspiciously like an hresult value.
    >
    > So the question is, how to I get the displayed value out of the cell
    > from my Ruby program?
    >
    > Thanks in advance for any help.
    >
    > Chris
    >
    >
    > --
    > seabird20
    > ------------------------------------------------------------------------
    > seabird20's Profile:
    > http://www.excelforum.com/member.php...o&userid=37033
    > View this thread: http://www.excelforum.com/showthread...hreadid=568252
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1