Resolver Hacks contains information and code for doing fun and useful things with Resolver One. This site is created and maintained by Michael Foord, not by Resolver Systems. Please read the disclaimer before using any of the code on this site.
The Main Module

Strictly speaking this is a hack, but occasionally it can be useful.
In Python the top-level script runs with the name __main__. That means that inside other modules you can get access to the namespace of the top-level script with import __main__.
In Resolver One, spreadsheets are also executed with the name __main__. Unfortunately though, probably as an artifact of the way that each spreadsheet is executed inside its own Python Engine, this import returns us a .NET 'module' object rather than a Python one. This means that you access names inside the spreadsheet namespace by indexing the Globals collection rather than through attributes on the module (as you would with a normal Python module).
The following snippet shows this in action, using a conditional hasattr so that it works with both .NET and Python modules:
import __main__
if hasattr(__main__, 'Globals'):
workbook = __main__.Globals['workbook']
else:
workbook = __main__.workbook
for col in range(10):
for row in range(10):
workbook['Sheet1'][col + 1, row + 1] = 'Hello World'
print 'Hello World'
If you put this code into a Python file, and import and call sayHello from a Resolver One spreadsheet, then it will populate 'Sheet1' with a 10x10 block of cells saying 'Hello World'. This is the helloworld module that comes with Resolverforge.
Last edited Sat Feb 09 00:59:49 2008.

IronPython in Action