Forums

Cobra and Excel - a code snippet using .NET Excel Wrapper

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Cobra and Excel - a code snippet using .NET Excel Wrapper

Postby ObtuseAngle » Mon Jun 06, 2011 10:58 pm

Greetings Cobra community!

Trying to move from Python and COM access to Excel to Cobra and .NET, after much tearing of hair I eventually gave up on trying to use the Primary Interop Assemblies directly and decided to make use of somebody else's hard work.

There are a few wrappers available, but for my needs .NET Excel Wrapper was fine:
http://excelwrapperdotnet.codeplex.com/
C# usage example and API docs given.

Hugely simplified Cobra snippet:
Code: Select all
use ExcelWrapper

class Program

    def main
        xl = ExcelWrapper.Wrapper()
        xl.open("c:\\temp\\somefile.xls", true)
        c = xl.getCellValue('B2')
        print c
        xl.close


The value of true makes Excel and the workbook visible (briefly, in this example).

Posted in the hope it will lighten somebody else's workload.

Regards, Obtuse.
99 programming bugs in the code, 99 bugs in the code, fix 1 bug and compile it again, 101 programming bugs in the code
ObtuseAngle
 
Posts: 42
Location: Gippsland, Australia

Re: Cobra and Excel - a code snippet using .NET Excel Wrappe

Postby Charles » Wed Jun 08, 2011 1:31 am

Excellent. Sometime in the near future, one will be able to conveniently inject @help in their source code to get the API info in a Cobra-friendly fashion, as a pop-up HTML document, like so:

xl = @help ExcelWrapper.Wrapper()


Not quite there yet, but I've started the implementation.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Cobra and Excel - a code snippet using .NET Excel Wrappe

Postby ObtuseAngle » Wed Jun 08, 2011 4:27 pm

Great!
That will be very (ahem) helpful - getting the API stuff correct is one of my biggest stumbling blocks in Cobra.
99 programming bugs in the code, 99 bugs in the code, fix 1 bug and compile it again, 101 programming bugs in the code
ObtuseAngle
 
Posts: 42
Location: Gippsland, Australia


Return to Discussion

Who is online

Users browsing this forum: No registered users and 45 guests