# Excel wrapper¶

This section describes how to use XLSDiscipline.

class gemseo.wrappers.xls_discipline.XLSDiscipline(xls_file_path, macro_name='execute')[source]

Wraps an excel workbook into a discipline.

Warning

As this wrapper relies on the xlswings library to handle macros and interprocess communication, it is only working under Windows and MacOS.

Initialize xls file path and macro.

Inputs must be specified in the “Inputs” sheet, in the following format (A and B are the first two columns)

A

B

a

1

b

2

Where a is the name of the first input, and 1 is its default value b is the name of the second one, and 2 its default value.

There must be no empty lines between the inputs

The number of rows is arbitrary but they must be contiguous and start at line 1

And same for the “Outputs” sheet (A and B are the first two columns)

A

B

c

3

Where c is the only output. There may be multiple.

if the file is a .xlsm, a macro named “execute” must exist and will be called by the _run method before retrieving the outputs. The macro has no arguments, it takes its inputs in the Inputs sheet, and write the outputs to the “Outputs” sheet

Alternatively, the user may provide a macro name to the constructor, or None if no macro shall be executed

Parameters
• xls_file_path (str) – path to the excel file if the file is a .xlsm, a macro named “execute” must exist and will be called by the _run method before retrieving the outputs

• macro_name (str) – name of the macro to be executed for a .xlsm file if None is provided, do not run a macro

The next figure illustrates how a macro can be wrapped to compute outputs from inputs.

Example of macro that can be wrapped