workbook_define_name

@brief Create a defined name in the workbook to use as a variable.

@param workbook Pointer to a lxw_workbook instance. @param name The defined name. @param formula The cell or range that the defined name refers to.

@return 0 for success, non-zero on error.

This method is used to defined a name that can be used to represent a value, a single cell or a range of cells in a workbook: These defined names can then be used in formulas:

@code workbook_define_name(workbook, "Exchange_rate", "=0.96"); worksheet_write_formula(worksheet, 2, 1, "=Exchange_rate", NULL);

@endcode

@image html defined_name.png

As in Excel a name defined like this is "global" to the workbook and can be referred to from any worksheet:

@code // Global workbook name. workbook_define_name(workbook, "Sales", "=Sheet1!$G$1:$H$10"); @endcode

It is also possible to define a local/worksheet name by prefixing it with the sheet name using the syntax 'sheetname!definedname':

@code // Local worksheet name. workbook_define_name(workbook, "Sheet2!Sales", "=Sheet2!$G$1:$G$10"); @endcode

If the sheet name contains spaces or special characters you must follow the Excel convention and enclose it in single quotes:

@code workbook_define_name(workbook, "'New Data'!Sales", "=Sheet2!$G$1:$G$10"); @endcode

The rules for names in Excel are explained in the [Microsoft Office documentation](http://office.microsoft.com/en-001/excel-help/define-and-use-names-in-formulas-HA010147120.aspx).

extern (C)
workbook_define_name
(,
const char* name
,
const char* formula
)

Meta