Solved

Data passing from DLL to Excel

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel/Word Add-in in what language? 5 118
VS2015 compilation and missing DLLs 9 147
Printing the elements of a set declared inside a map in C++. 3 47
Problem with SqlConnection 4 168
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

786 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