Accessing indexed properties with more than 1 key / writing

Posted by Haikarainen on 03-Apr-2012 07:27

My goal is to use the Microsoft.Office.Interop.Excel.Worksheet-class to write content straight into said worksheet(wich I have available via the Application-class).

This class uses an indexed property (Worksheet:Range) wich is used to access Cells throughout the worksheet. I've done some reading and according to what I've read, ABL doesn't support Indexed properties with more than 1 key, wich means there is no way for me to make use of this property, and  through that and what I want to achieve, the whole Worksheet-class.

Note: .NET documentation strongly recommends that any indexed property should only be
created with one key for the indexer, and this is how all indexed properties are defined
for the Microsoft .NET Framework. However, it is possible that other third-party .NET
classes could define indexed properties with two or more keys for the indexer, in which
case you cannot access those indexed properties in ABL.

I've also read on some Microsoft documentation about accessing the Range-property, and the preffered way to do it nowadays is by accessing it with () instead of [], to make it more "C#-friendly". This is something that OpenEdge ABL apparently refuses to work with, it just nags about Range-method not being found.

My attempts on accesing this property have been pretty desperate and I've tried a wide Range of things:

Worksheet:Range["A1"]:Formula     /* Compiles, but Range["A1"] is null/? causing a crash.*/

Worksheet:Range[0]:Formula        /* -"- */

Worksheet:Range(0):Formula        /* Syntax check: "Couldn't find element Range in class"*/

Worksheet:Range:Formula           /* Syntax check: "Indexed property can only be accessed with indexer/key in parentheses"

Edit: CTRL+S reflex posted the message, following:

My question is; Is there ANY way to access this indexed property with proper keys? What are my other options? I saw Infragistics had some Excel-class, is that something I could use? Like create a whole new XLS-file with that class, then just load that file with my excel.application-class?

Thanks in advance,

All Replies

Posted by Admin on 03-Apr-2012 07:36

I have written a small C# helper for that purpose.

Posted by Haikarainen on 03-Apr-2012 07:54

Care to elaborate? Is it something like an imported assembly reference wich you made with C# that provides functions to access general indexed properties or a fixed collection of selfdefined properties? Any help is appreciated!

Posted by Admin on 03-Apr-2012 08:46

Pretty much like you have described.

If you don't have a Visual Studio license at hand, get a free C# Express. When building your assembly, just make sure you build it using .NET 3.x for 10.2B and if you dare .NET 4.0 for OE11.

Either build static methods (like in the Progress.Util helper classes) or regular methods, depending on personal preference and use case.

For the case of Excel you'll have to add a reference to the Excel interop assembly to the C# solution.

Compile it as a class library and add it to you ABL referenced assemblies (assemblies.xml).

It's almost as easy as described in Gus' April 1st blog post to enhance the ABL

Posted by Haikarainen on 03-Apr-2012 09:03

Thanks a lot! I've allready started working on it but the details you provided really cleared stuff up a bit

This thread is closed