Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Data passing from DLL to Excel

Posted on 2000-04-23
2
Medium Priority
?
211 Views
Last Modified: 2010-04-02
Hi,

I deadly need your help.

What I am trying to do is to call a DLL and get some data under Excel 97. The input data from Excel to the DLL is real-time data, and I need to get back 5 "double" variables calculated by the DLL written by C++. In Excel, I can call the DLL 5 times in 5 different cells to get all of them, but each call will repeat the same calculation. Due to the HEAVE computation, five calls are very slow. These five data is calculated from the same single computation procedure, so I want to put them in an array and have the array passed back to Excel by one call. Under Excel, the data type code for the arry is "K", and the array should be decalred as FP in the DLL(Detail of this can be found at http://msdn.microsoft.com/library/officedev/office97/SEC7C.htm). I tried to work it out, but failed. There is no sample codes from Microsoft, and I could not find any help from its Excel 97 developer's kit book.

Please give me some helps. If possible, please post your source codes.

Many thanks.
0
Comment
Question by:jasonwan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
wylliker earned 40 total points
ID: 2742900
Why not modify your DLL ...
Instead of calculating everytime you call into the DLL add another parameter.

Sort of like ...

double  GetValue(unsigned short Index, unsigned short fRecalculate)

In Excel just call the function for each value (the index parameter could be the index into an array in your DLL)and only pass the recalculate flag as 1 (true) on the first call (and subsequently on the first call the next time you need updated data) and as 0 (false) for the other 4 calls.  

This way you avoid having to get into passing any arrays and the overhead to support this.

For example:

  GetValue(0, 1)
  GetValue(1, 0)
  GetValue(2, 0)
  GetValue(3, 0)
  GetValue(4, 0)

Only on the first call would you calculate all of the doubles into an array.

In your GetValue function you would have ...

  double GetValue(unsigned short Index, unsigned short fRecalculate)
{
  if(fRecalculate)
  {
     Calculate() // whatever you may need to do this
  }

  if(Index < MAX_INDEX)
     return Array[Index];
}


Something like what I have described ought to work for you








0
 
LVL 3

Expert Comment

by:altena
ID: 2743202
wylliker: Thats an answer. Looks good enough to me.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question