Solved

Data passing from DLL to Excel

Posted on 2000-04-23
2
209 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 10 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

635 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