Use of Excel APIs for multiple versions of Excel

  • Thread starter Ronnie Thompson
  • Start date
R

Ronnie Thompson

I am working on a C# application that generates Excel spreadsheets using
Excel APIs. My scope includes support of Excel 2000 and greater (Excel 2002,
Excel 2003) etc. Unfortunately, the required parameters for each API have
changed with the different versions of Excel. For example, my program works
fine with Excel 2000, but does not work with Excel 2002 or Excel 2003 because
the APIs have changed.

What is the best strategy to use so I can write the application as simple as
possible, but at the same time support the various versions of Excel that are
available including yet to be released versions?

I know there are third party tools available, however I do not want to
increase the license cost of the product and require third party software
licenses when the user of my application already has Excel.
 
J

Jim Rech

I'm not sure what you mean by an "API". Can you give us an example of one
you feel has changed?

--
Jim Rech
Excel MVP
message |I am working on a C# application that generates Excel spreadsheets using
| Excel APIs. My scope includes support of Excel 2000 and greater (Excel
2002,
| Excel 2003) etc. Unfortunately, the required parameters for each API have
| changed with the different versions of Excel. For example, my program
works
| fine with Excel 2000, but does not work with Excel 2002 or Excel 2003
because
| the APIs have changed.
|
| What is the best strategy to use so I can write the application as simple
as
| possible, but at the same time support the various versions of Excel that
are
| available including yet to be released versions?
|
| I know there are third party tools available, however I do not want to
| increase the license cost of the product and require third party software
| licenses when the user of my application already has Excel.
 
R

Rob Bovey

If I recall correctly, C# doesn't support optional arguments the same
way VB does. When you call a method you have to pass all the arguments,
optional or otherwise (there's some kind of special empty value you pass
when you aren't going to use the optional argument). So, for example, when
they added a ton of optional arguments to the Worksheet.Protect method
between Excel 2000 and 2002 it looks the same from VB but completely
different from C#. No idea what the solution is though.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 
K

K Dales

There does not seem to be an "easy" solution since somehow your code will
need to account for any of the changes, and without some sort of specialized
tool that can only be done by writing code to deal with any differences. I
can only suggest that you could create a custom class (not sure the proper C#
terminology?) including the Excel API within the class - then pass a
"generic" set of arguments to your new "versionless" Excel object that you
can modify (according to version) and pass to the actual API. Makes it
easier to use down the road, but it would be a lot of up-front work (which is
why people can sell this type of thing as a 3rd party product!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top