API Reference¶
This is the class and function reference of xlcompose. Please refer to the full user guide for further details, as the class and function raw specifications may not be enough to give full guidelines on their uses. For reference on concepts repeated across the API, see glossary.
xlcompose.core
¶
- class xlcompose.core.CSpacer(height=1, row_heights=None, *args, **kwargs)¶
A blank horizontal space in a Column container.
- Parameters
- height: int
Height (in number of rows) of the CSpacer
- row_heights: float
The height to apply to each row of the CSpacer
- Attributes
- row_heights
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.Column(*args, **kwargs)¶
A container object respresenting a vertical layout of other xlcompose objects.
- Parameters
- args:
Any xlcompose objects with the exception of Sheet and Tabs
- Attributes
- heightint
Height of the container and is a function of the elements it contains
- widthint
Width of the container and is a function of the elements it contains
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.DataFrame(data, formats=None, header=True, header_formats=None, col_nums=False, index=True, index_label='', index_formats=None, column_widths=None, row_heights=None, *args, **kwargs)¶
An Excel-ready DataFrame.
- Attributes
- row_heights
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.HSpacer(height=1, row_heights=None, *args, **kwargs)¶
- Attributes
- row_heights
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.Image(data, width=1, height=1, formats={}, *args, **kwargs)¶
Image allows for the embedding of images into a spreadsheet
- Parameters
- datastr
path to the image file, e.g. sample.png or ./sample.jpg or a matplotlib AxesSubplot
- widthint
the number of columns consumed by the image
- heightint
the number of rows consumed by the image
- formatsdict
xlsxwriter options for modifying the image
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.RSpacer(width=1, column_widths=2.25, *args, **kwargs)¶
A blank vertical space in a Row container.
- Parameters
- width: int
Width (in number of columns) of the RSpacer
- column_widths: float
The width to apply to each column of the RSpacer
- Attributes
- row_heights
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.Row(*args, **kwargs)¶
A container object respresenting a horizontal layout of other xlcompose objects.
- Parameters
- args:
Any xlcompose objects with the exception of Sheet and Tabs
- Attributes
- heightint
Height of the container and is a function of the elements it contains
- widthint
Width of the container and is a function of the elements it contains
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.Series(data, formats=None, width=1, column_widths=1, row_heights=None, *args, **kwargs)¶
Excel-ready Series object. This component does not render the index or series name. To include those, see the DataFrame component.
- Parameters
- datalist or Series
The data to be placed into the series
- formatslist
The formats to be applied to the Series. Each element in the Series will be assigned a format from this list with the corresponding index.
- widths: int
The number of columns the Series should span. For values higher than 1, the columns spanned will be merged.
- column_widthslist
list of floats representing the column widths of each column within the DataFrame. If omitted, then widths are set by inspecting the data.
- row_heightslist
list of floats representing the row heights of each row within the Series. If omitted, then heights are set by inspecting the data.
- Attributes
- column_widths
- row_heights
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.Sheet(name, layout, **kwargs)¶
A container object representing an Excel worksheet.
- Parameters
- namestr
The name of the worksheet
- layout :
An xlcompose object
- fit_to_pages:
refer to xlsxwriter for fit_to_pages options
- freeze_panes:
refer to xlsxwriter for freeze_panes options
- set_page_view:
refer to xlsxwriter for set_page_view options
- print_row_col_headers:
refer to xlsxwriter for print_row_col_headers options
- hide_row_col_headers:
refer to xlsxwriter for hide_row_col_headers options
- center_vertically:
refer to xlsxwriter for center_vertically options
- center_horizontally:
refer to xlsxwriter for center_horizontally options
- set_header:
refer to xlsxwriter for set_header options
- set_footer:
refer to xlsxwriter for set_footer options
- repeat_rows:
refer to xlsxwriter for repeat_rows options
- repeat_columns:
refer to xlsxwriter for repeat_columns options
- set_margins:
refer to xlsxwriter for set_margins options
- hide_gridlines:
refer to xlsxwriter for hide_gridlines options
- set_print_scale:
refer to xlsxwriter for set_print_scale options
- set_start_page:
refer to xlsxwriter for set_start_page options
- set_h_pagebreaks:
refer to xlsxwriter for set_h_pagebreaks options
- set_v_pagebreaks:
refer to xlsxwriter for set_v_pagebreaks options
- print_across:
refer to xlsxwriter for print_across options
- print_area:
refer to xlsxwriter for print_area options
- set_paper:
refer to xlsxwriter for set_paper options
- set_landscape:
refer to xlsxwriter for set_landscape options
- set_portrait:
refer to xlsxwriter for set_portrait options
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.Tabs(*args, **kwargs)¶
A container object representing multiple worksheets.
- Parameters
- args:
A list of sheets or a tuple with a sheet name and any xlcompose object. For example, (‘sheet1’, xlc.DataFrame(data))
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.Title(data, formats=[], width=None, column_widths=None, row_heights=None, *args, **kwargs)¶
Title objects are Series-like objects that has its own formatting style.
Difference between a Series and a Title is that a Title width will be inferred from its container. Additionally, Title objects have a different default format.
- Parameters
- datastr or list of str
Title and subtitle texts
- formatslist
The formats to be applied to the Title. Each element in the Title will be assigned a format from this list with the corresponding index.
- width :
The width the title should span. If omitted, the title will take on the width of its container.
- column_widthslist
list of floats representing the column widths of each column within the DataFrame. If omitted, then widths are set by inspecting the data.
- row_heightslist
list of floats representing the row heights of each row within the Series. If omitted, then heights are set by inspecting the data.
- Attributes
- column_widths
- row_heights
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.core.VSpacer(width=1, column_widths=2.25, *args, **kwargs)¶
- Attributes
- row_heights
Methods
to_excel
(workbook_path[, default_formats])Outputs object to Excel.
- class xlcompose.templates.EvalExtension(environment: jinja2.environment.Environment)¶
enabled the { % eval %}{% endeval %} jinja functionality
Methods
attr
(name[, lineno])Return an attribute node for the current extension.
bind
(environment)Create a copy of this extension bound to another environment.
call_method
(name[, args, kwargs, dyn_args, ...])Call a method of the extension.
filter_stream
(stream)It's passed a
TokenStream
that can be used to filter tokens returned.parse
(parser)If any of the
tags
matched this method is called with the parser as first argument.preprocess
(source, name[, filename])This method is called before the actual lexing and can be used to preprocess the source.
- parse(parser)¶
If any of the
tags
matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes.
- xlcompose.templates.load_json(template, env=None, **kwargs)¶
Loads a JSON template specifying the structure of the XLCompose Object.
- xlcompose.templates.load_yaml(template, env=None, str_only=False, **kwargs)¶
Loads a YAML template specifying the structure of the XLCompose Object.