Cobra and Excel - a code snippet using .NET Excel Wrapper
Posted: 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:
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.
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.