"cim" <cim@discussions.microsoft.comha scritto nel messaggio
news:09596B69-0D21-435B-9CB1-A042424E73F8@microsoft.com...
Quote:
I would like to be able to write generic (i.e. non-managed) C++ code which
I
could use in a library with Excel as the front end. I would like to be
able
to maintain a code base that will compile in a non-windows environment.
|
For the non-windows environments, you can use multiplatform and standard
libraries, like STL.
For example, if you want to store an array of data, you have several
options: you could use CAtlArray (from ATL), but it is Windows-specific.
Another option is to use std::vector from STL, which will compile fine also
on non-Windows platforms.
You can design your code separating the multiplatform part (written in
standard C++, using standard and multiplatform libraries like STL), from the
Windows-specific part.
The Windows-specific part should use COM to export the multiplatform "core"
part towards Excel.
Excel (and Office in general) are heavy based on COM technology, so I think
that COM is the way to go if you want to extend Excel from native C++.
A possible architecture could be like the following:
- core part (standard C++, STL)
- COM objects wrapping the "core" (built with C++ with ATL)
- VBA code in Excel that calls the COM objects
There is also another option to built Excel add-ins, using XLL technique
that does not require COM.
It is explained a bit here:
http://support.microsoft.com/kb/178474
However, I think that it is a legacy technology, and I would definitely
suggest using COM for that job.
Giovanni