Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Accessing Excel cell which made call to C# dll ...

Accessing Excel cell which made call to C# dll ...

Scheduled Pinned Locked Moved C#
csharpcomtutorialquestionannouncement
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gvanto
    wrote on last edited by
    #1

    I am trying to figure out if there's a way I can keep an Excel cell updated as follows: I have created a C# dll, with a function: double pf2GetPrice(string ticker) which returns the price of a ticker, when calling this function in a cell in Excel - it works nicely. To keep the cell value current, I'd like to loop within the dll and update the calling cell's value. Can this be done? (i'm guessing it must be possible) I've only come across this so far, but its not a very good tutorial: http://msdn.microsoft.com/en-us/library/bb687861.aspx[^] Any advice would be much appreciated, G C# dll newbie

    Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

    M 1 Reply Last reply
    0
    • G gvanto

      I am trying to figure out if there's a way I can keep an Excel cell updated as follows: I have created a C# dll, with a function: double pf2GetPrice(string ticker) which returns the price of a ticker, when calling this function in a cell in Excel - it works nicely. To keep the cell value current, I'd like to loop within the dll and update the calling cell's value. Can this be done? (i'm guessing it must be possible) I've only come across this so far, but its not a very good tutorial: http://msdn.microsoft.com/en-us/library/bb687861.aspx[^] Any advice would be much appreciated, G C# dll newbie

      Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      You are trying to do the work from the wrong end, the loop should logically be in the Excel program. I guess you could have the sheet register itself with the DLL and have a time running to update the sheet (how I have no idea but it may be possible).

      Never underestimate the power of human stupidity RAH

      G 1 Reply Last reply
      0
      • M Mycroft Holmes

        You are trying to do the work from the wrong end, the loop should logically be in the Excel program. I guess you could have the sheet register itself with the DLL and have a time running to update the sheet (how I have no idea but it may be possible).

        Never underestimate the power of human stupidity RAH

        G Offline
        G Offline
        gvanto
        wrote on last edited by
        #3

        Why do you think its 'logical' to have the looping in the excel sheet? (to me its more logical to have the dll doing the 'updating' ... leaving the sheet user to not worry about constantly refreshing it. I'm just thinking about all the dll's out there that keep cell data updated dynamically (bloomberg API for example) ... ? Therefore I think it must defo be possible help much appreciated, g

        Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

        M 1 Reply Last reply
        0
        • G gvanto

          Why do you think its 'logical' to have the looping in the excel sheet? (to me its more logical to have the dll doing the 'updating' ... leaving the sheet user to not worry about constantly refreshing it. I'm just thinking about all the dll's out there that keep cell data updated dynamically (bloomberg API for example) ... ? Therefore I think it must defo be possible help much appreciated, g

          Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Standard OO design, the parent (the dll) has no knowledge of the child (excel). It's like having the web service having to know and keep track of about every subscriber. What happens when you have 2 sheets wanting to get the data from the DLL? Mind you if the DLL is an abstraction layer between the web service and the excel sheet and is instantiated for each sheet to be serviced then you are right the DLL can do the management. This would give you something like: Sheet wakes up Instantiates DLL DLL gets reference to target cells DLL starts timer loop DLL gets data from service (pre difined in DLL) DLL feeds sheet DLL repeats

          Never underestimate the power of human stupidity RAH

          G 1 Reply Last reply
          0
          • M Mycroft Holmes

            Standard OO design, the parent (the dll) has no knowledge of the child (excel). It's like having the web service having to know and keep track of about every subscriber. What happens when you have 2 sheets wanting to get the data from the DLL? Mind you if the DLL is an abstraction layer between the web service and the excel sheet and is instantiated for each sheet to be serviced then you are right the DLL can do the management. This would give you something like: Sheet wakes up Instantiates DLL DLL gets reference to target cells DLL starts timer loop DLL gets data from service (pre difined in DLL) DLL feeds sheet DLL repeats

            Never underestimate the power of human stupidity RAH

            G Offline
            G Offline
            gvanto
            wrote on last edited by
            #5

            Ok I see, makes sense yeah thank you G

            Find Your Dream Job in Australia, Free! http://www.WebCV.com.au

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups