Columns generated by code

At the end of Start Using Resolver One, we mention that you can write code so that you don't have to paste the Gross Price formula into every cell in column C. This sample shows you how to do that.

Before you begin

Do one of the following to open the example workbook:

  • In Windows, select Start, Resolver One, Samples, Columns generated by code.
  • Download the file from the Resolver Exchange.

The example worksheet

The grid looks precisely as it did in the earlier sample. However, if you double-click on the cells below "Gross Price" you will see that there is nothing there! How are the numbers generated?

To find out, you need to examine the user code...

The user code

The Pre-formulae user code contains the following:

for row in workbook["Sheet1"].ContentRows:
    row["Gross Price"] = withVAT(row["Net Price"])

If you add a new item to the bottom of the list—e.g. try typing "Pencil" into A9 and "0.10" into B9—the gross price is automatically recalculated and displayed.

Comments