Cell DSL API

Traits

Traits represent abstract properties that various operations may have

Data

Commands with this trait provide some data to the function for writing.

DataType

Commands with this trait parametrize data_type, generally assuming Data trait is also present.

Format

Commands with this trait provide some format_ to the function for writing.

RelativePosition

Commands with this trait target a cell relative to the current cell.

AbsolutePosition

Commands with this aspect target a specific cell at row and col

FractionalSize

Commands with this trait require some kind of real-valued size

CardinalSize

Commands with this trait require some kind of integer size

Range

Commands with this trait target a range of cells bounded by a box with top_left_point and bottom_right_point.

NamedPoint

Commands with this trait give a temporary point_name to the cell to be referenced later.

ForwardRef

Commands with this trait manage a list of resolve_refs.

Options

Commands with this trait have a dictionary of options

ExecutableCommand

Commands with this trait are active commands representing actions that will be done in the worksheet.

class xlsxwriter_celldsl.ops.traits.AbsolutePosition(row: int = - 1, col: int = - 1)[source]

Commands with this aspect target a specific cell at row and col

c(col: numbers.Integral) xlsxwriter_celldsl.ops.traits.T[source]

Target the cell at col for this object.

r(row: numbers.Integral) xlsxwriter_celldsl.ops.traits.T[source]

Target the cell at row for this object.

class xlsxwriter_celldsl.ops.traits.CardinalSize(size: int = 0)[source]

Commands with this trait require some kind of integer size

with_size(size: numbers.Integral) xlsxwriter_celldsl.ops.traits.T[source]

Specify the integral size for this object.

class xlsxwriter_celldsl.ops.traits.Data(data: Any = '')[source]

Commands with this trait provide some data to the function for writing.

with_data(data: Any) xlsxwriter_celldsl.ops.traits.T[source]

Specify the data for this object.

class xlsxwriter_celldsl.ops.traits.DataType(data_type: Optional[str] = None)[source]

Commands with this trait parametrize data_type, generally assuming Data trait is also present.

with_data_type(data_type: Optional[str])[source]

Force the write to use a specific method or default to generic write if data_type is None.

Accepted values are: string, number, blank, formula, datetime, boolean, url and None

See also

write()

class xlsxwriter_celldsl.ops.traits.ExecutableCommand[source]

Commands with this trait are active commands representing actions that will be done in the worksheet.

class xlsxwriter_celldsl.ops.traits.Format(set_format: Optional[xlsxwriter_celldsl.formats.FormatDict] = None)[source]

Commands with this trait provide some format_ to the function for writing.

set_base_format(format_)[source]

Set the fallback format globally for the entire project. This format will be used in absence of set_format and all formats later will merge with it.

with_format(format_) xlsxwriter_celldsl.ops.traits.T[source]

Specify the format_ for this object.

class xlsxwriter_celldsl.ops.traits.ForwardRef(resolved_refs: Dict[str, str] = NOTHING)[source]

Commands with this trait manage a list of resolve_refs.

class xlsxwriter_celldsl.ops.traits.FractionalSize(size: float = 0.0)[source]

Commands with this trait require some kind of real-valued size

with_size(size: numbers.Real) xlsxwriter_celldsl.ops.traits.T[source]

Specify the real-valued size for this object.

class xlsxwriter_celldsl.ops.traits.NamedPoint(point_name: str = '__DEFAULT')[source]

Commands with this trait give a temporary point_name to the cell to be referenced later.

at(point_name) xlsxwriter_celldsl.ops.traits.T[source]

Specify the point_name for this object.

class xlsxwriter_celldsl.ops.traits.Options(options: Dict[str, Any] = NOTHING)[source]

Commands with this trait have a dictionary of options

with_options(options: Dict[str, Any])[source]

Add new options to our configuration.

class xlsxwriter_celldsl.ops.traits.Range(top_left_point: Union[str, int, Tuple[int, int]] = 0, bottom_right_point: Union[str, int, Tuple[int, int]] = 0)[source]

Commands with this trait target a range of cells bounded by a box with top_left_point and bottom_right_point.

Notes

top_left_point and bottom_right_point have different behavior depending on the value type

  • If it’s a string, this will be the save point name at which the save occurs.

  • If it’s an Integral

    • If positive: this will be last n-th visited cell.

    • If negative: this will be last n-th position in save stack which will be retrieved without popping it from the stack.

    • If zero, current cell will be the target.

  • If it’s Coords, it will be the absolute coords of the cell.

with_bottom_right(point: Union[str, int, Tuple[int, int]])[source]

Specify bottom right corner point for this object.

with_top_left(point: Union[str, int, Tuple[int, int]])[source]

Specify top left corner point for this object.

class xlsxwriter_celldsl.ops.traits.RelativePosition(row: int = 0, col: int = 0)[source]

Commands with this trait target a cell relative to the current cell.

c(delta_col: numbers.Integral) xlsxwriter_celldsl.ops.traits.T[source]

Specify a target delta_col away from current position for this object.

r(delta_row: numbers.Integral) xlsxwriter_celldsl.ops.traits.T[source]

Specify a target delta_row away from current position for this object.

Operations

Operations are the commands that are executed after they’re committed

MoveOp

A command to move r() rows and c() columns away from current cell.

AtCellOp

A command to go to a cell r() and c().

BacktrackCellOp

A command to rewind() the position back in time.

StackSaveOp

A command to push current location into save stack.

StackLoadOp

A command to pop last location from save stack and jump to it.

LoadOp

A command to jump to at() a save point.

SaveOp

A command to save current location at() memory location.

RefArrayOp

A forward reference to an array of cells with_name() defined using a rectangle with top_left() and bottom_right() specified.

SectionBeginOp

A command that does nothing, but may assist in debugging and documentation of scripts by giving providing segments in script with_name().

SectionEndOp

A command that indicates an end of the most recent SectionBeginOp.

WriteOp

A command to write to this cell with_data() with data with_data_type() and with_format().

MergeWriteOp

A command to merge with_size() cols starting from current col and write with_data() with data with_data_type() and with_format() into this cell.

WriteRichOp

A command to write a text run with_data() and with_format() to current position, then() perhaps write some more, optionally with_default_format().

ImposeFormatOp

A command to append to merge current cell’s format with_format().

OverrideFormatOp

A command to override current cell’s format with_format().

DrawBoxBorderOp

Draw a box with borders where top_left_point and bottom_right_point are respective corners using (right|top|left|bottom)_formats.

DefineNamedRangeOp

A command to make a box with_top_left() and with_bottom_right() which are respective corners of a range with_name().

SetRowHeightOp

A command to set current row’s height with_size().

SetColumnWidthOp

A command to set current column’s height with with_size().

SubmitHPagebreakOp

A command to submit a horizontal page break at current row.

SubmitVPagebreakOp

A command to submit a vertical page break at current row.

ApplyPagebreaksOp

A command to apply all existing pagebreaks.

AddCommentOp

A command to add a comment to this cell with_data(), configured with_options().

AddChartOp

A command to add a chart to this cell perhaps with_subtype() and then do() call some methods on the associated target class.

AddConditionalFormatOp

A command to add a conditional format to a range of cells with_top_left() and with_bottom_right() corners parametrized with_options().

AddImageOp

A command to add an image to this cell either getting it with_filepath() or constructing it with_image_data(), parametrized with_options().

SetPrintAreaOp

A command that allows to set the printed area of the sheet as a box with_top_left() and with_bottom_right()

class xlsxwriter_celldsl.ops.classes.AddChartOp(NAME_STACK_DATA: List[str] = NOTHING, resolved_refs: Dict[str, str] = NOTHING, type: str = 'bar', subtype: Optional[str] = None, target: xlsxwriter_celldsl.ops.classes.T = NOTHING, action_chain: List[Tuple[str, Tuple[Any, ...], Dict[str, Any]]] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.ExecutableCommand, xlsxwriter_celldsl.ops.traits.ForwardRef, Generic[xlsxwriter_celldsl.ops.classes.T]

A command to add a chart to this cell perhaps with_subtype() and then do() call some methods on the associated target class.

do(command_list)[source]

Add command_list to action_chain

Example

>>> from xlsxwriter_celldsl.ops import AddLineChart, AddBarChart, RefArray
... AddLineChart.do([
...     # You really should only use `target` attribute of this class
...     AddLineChart.target.add_series({'values': '=SheetName!$A$1:$D$1'}),
...     # Charts allow to use `RefArray` in place of literal cell ranges
...     AddLineChart.target.add_series({'values': RefArray.at('some ref')}),
...     # Combine method accepts AddChartOp
...     AddLineChart.target.combine(
...         # This will combine this line chart with a bar chart
...         AddBarChart.do([])
...     )
... ])
class xlsxwriter_celldsl.ops.classes.AddCommentOp(NAME_STACK_DATA: List[str] = NOTHING, data: Any = '', options: Dict[str, Any] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.Data, xlsxwriter_celldsl.ops.traits.Options, xlsxwriter_celldsl.ops.traits.ExecutableCommand

A command to add a comment to this cell with_data(), configured with_options().

class xlsxwriter_celldsl.ops.classes.AddConditionalFormatOp(NAME_STACK_DATA: List[str] = NOTHING, top_left_point: Union[str, int, Tuple[int, int]] = 0, bottom_right_point: Union[str, int, Tuple[int, int]] = 0, options: Dict[str, Any] = NOTHING, set_format: Optional[xlsxwriter_celldsl.formats.FormatDict] = None)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.ExecutableCommand, xlsxwriter_celldsl.ops.traits.Range, xlsxwriter_celldsl.ops.traits.Options, xlsxwriter_celldsl.ops.traits.Format

A command to add a conditional format to a range of cells with_top_left() and with_bottom_right() corners parametrized with_options().

To configure the format, you can either use with_format() or specify the FormatDict as format key in options. Do not use both at the same time however.

class xlsxwriter_celldsl.ops.classes.AddImageOp(NAME_STACK_DATA: List[str] = NOTHING, options: Dict[str, Any] = NOTHING, file_path: str = '')[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.ExecutableCommand, xlsxwriter_celldsl.ops.traits.Options

A command to add an image to this cell either getting it with_filepath() or constructing it with_image_data(), parametrized with_options().

class xlsxwriter_celldsl.ops.classes.ApplyPagebreaksOp(NAME_STACK_DATA: List[str] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command to apply all existing pagebreaks. Should come after all SubmitHPagebreakOp and SubmitVPagebreakOp have been committed.

class xlsxwriter_celldsl.ops.classes.AtCellOp(NAME_STACK_DATA: List[str] = NOTHING, row: int = - 1, col: int = - 1)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.AbsolutePosition

A command to go to a cell r() and c().

class xlsxwriter_celldsl.ops.classes.BacktrackCellOp(NAME_STACK_DATA: List[str] = NOTHING, n: int = 0)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command to rewind() the position back in time. 0 stays in current cell, 1 goes to previous cell…

class xlsxwriter_celldsl.ops.classes.DrawBoxBorderOp(NAME_STACK_DATA: List[str] = NOTHING, top_left_point: Union[str, int, Tuple[int, int]] = 0, bottom_right_point: Union[str, int, Tuple[int, int]] = 0, right_format: Mapping = {'right': 1}, top_format: Mapping = {'top': 1}, left_format: Mapping = {'left': 1}, bottom_format: Mapping = {'bottom': 1})[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.Range

Draw a box with borders where top_left_point and bottom_right_point are respective corners using (right|top|left|bottom)_formats.

class xlsxwriter_celldsl.ops.classes.ImposeFormatOp(NAME_STACK_DATA: List[str] = NOTHING, set_format={})[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.Format

A command to append to merge current cell’s format with_format().

class xlsxwriter_celldsl.ops.classes.LoadOp(NAME_STACK_DATA: List[str] = NOTHING, point_name: str = '__DEFAULT')[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.NamedPoint

A command to jump to at() a save point.

class xlsxwriter_celldsl.ops.classes.MergeWriteOp(NAME_STACK_DATA: List[str] = NOTHING, size: int = 0, data: Any = '', data_type: Optional[str] = None, set_format: Optional[xlsxwriter_celldsl.formats.FormatDict] = None)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.CardinalSize, xlsxwriter_celldsl.ops.traits.Data, xlsxwriter_celldsl.ops.traits.DataType, xlsxwriter_celldsl.ops.traits.Format, xlsxwriter_celldsl.ops.traits.ExecutableCommand

A command to merge with_size() cols starting from current col and write with_data() with data with_data_type() and with_format() into this cell.

class xlsxwriter_celldsl.ops.classes.MoveOp(NAME_STACK_DATA: List[str] = NOTHING, row: int = 0, col: int = 0)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.RelativePosition

A command to move r() rows and c() columns away from current cell.

class xlsxwriter_celldsl.ops.classes.OverrideFormatOp(NAME_STACK_DATA: List[str] = NOTHING, set_format: Optional[xlsxwriter_celldsl.formats.FormatDict] = None)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.Format

A command to override current cell’s format with_format().

class xlsxwriter_celldsl.ops.classes.RefArrayOp(NAME_STACK_DATA: List[str] = NOTHING, top_left_point: Union[str, int, Tuple[int, int]] = 0, bottom_right_point: Union[str, int, Tuple[int, int]] = 0, point_name: str = '__DEFAULT')[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.Range, xlsxwriter_celldsl.ops.traits.NamedPoint

A forward reference to an array of cells with_name() defined using a rectangle with top_left() and bottom_right() specified. This is only used in charts.

This is also a marker for such an array, meaning in commands that support forward references, you can use RefArray.at(‘name’) to use a reference, which will be replaced with a string like '=SheetName!$C$1:$F$9'.

class xlsxwriter_celldsl.ops.classes.SaveOp(NAME_STACK_DATA: List[str] = NOTHING, point_name: str = '__DEFAULT')[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.NamedPoint

A command to save current location at() memory location.

class xlsxwriter_celldsl.ops.classes.SectionBeginOp(NAME_STACK_DATA: List[str] = NOTHING, name: str = '__UNNAMED')[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command that does nothing, but may assist in debugging and documentation of scripts by giving providing segments in script with_name().

During execution, if an error occurs, the surrounding names will be displayed, in order from most recent to least recent.

class xlsxwriter_celldsl.ops.classes.SectionEndOp(NAME_STACK_DATA: List[str] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command that indicates an end of the most recent SectionBeginOp.

class xlsxwriter_celldsl.ops.classes.SetColumnWidthOp(NAME_STACK_DATA: List[str] = NOTHING, size: float = 0.0)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.FractionalSize, xlsxwriter_celldsl.ops.traits.ExecutableCommand

A command to set current column’s height with with_size().

class xlsxwriter_celldsl.ops.classes.SetPrintAreaOp(NAME_STACK_DATA: List[str] = NOTHING, top_left_point: Union[str, int, Tuple[int, int]] = 0, bottom_right_point: Union[str, int, Tuple[int, int]] = 0)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.ExecutableCommand, xlsxwriter_celldsl.ops.traits.Range

A command that allows to set the printed area of the sheet as a box with_top_left() and with_bottom_right()

class xlsxwriter_celldsl.ops.classes.SetRowHeightOp(NAME_STACK_DATA: List[str] = NOTHING, size: float = 0.0)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.FractionalSize, xlsxwriter_celldsl.ops.traits.ExecutableCommand

A command to set current row’s height with_size().

class xlsxwriter_celldsl.ops.classes.StackLoadOp(NAME_STACK_DATA: List[str] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command to pop last location from save stack and jump to it.

class xlsxwriter_celldsl.ops.classes.StackSaveOp(NAME_STACK_DATA: List[str] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command to push current location into save stack.

class xlsxwriter_celldsl.ops.classes.SubmitHPagebreakOp(NAME_STACK_DATA: List[str] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command to submit a horizontal page break at current row. This is preserved between several cell_dsl_context.

class xlsxwriter_celldsl.ops.classes.SubmitVPagebreakOp(NAME_STACK_DATA: List[str] = NOTHING)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command

A command to submit a vertical page break at current row. This is preserved between several cell_dsl_context.

class xlsxwriter_celldsl.ops.classes.WriteOp(NAME_STACK_DATA: List[str] = NOTHING, data: Any = '', data_type: Optional[str] = None, set_format: Optional[xlsxwriter_celldsl.formats.FormatDict] = None)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.Data, xlsxwriter_celldsl.ops.traits.DataType, xlsxwriter_celldsl.ops.traits.Format, xlsxwriter_celldsl.ops.traits.ExecutableCommand

A command to write to this cell with_data() with data with_data_type() and with_format().

class xlsxwriter_celldsl.ops.classes.WriteRichOp(NAME_STACK_DATA: List[str] = NOTHING, data: Any = '', set_format: Optional[xlsxwriter_celldsl.formats.FormatDict] = None, default_format=NOTHING, cell_format: Optional[xlsxwriter_celldsl.formats.FormatDict] = None, prev_fragment: Optional[WriteRichOp] = None)[source]

Bases: xlsxwriter_celldsl.ops.classes.Command, xlsxwriter_celldsl.ops.traits.Data, xlsxwriter_celldsl.ops.traits.Format, xlsxwriter_celldsl.ops.traits.ExecutableCommand

A command to write a text run with_data() and with_format() to current position, then() perhaps write some more, optionally with_default_format().

Additionally, the first WriteRichOp may also set this cell with_cell_format().

then(fragment: xlsxwriter_celldsl.ops.classes.WriteRichOp)[source]

Submit additional fragments of the rich string

with_cell_format(format: Optional[xlsxwriter_celldsl.formats.FormatDict])[source]

If format is not None, then set the cell format to be set to the cell upon writing.

This method does not implicitly merge with DEFAULT_FORMAT.

with_default_format(other)[source]

Set format for fragments without a format. Should be applied to the first fragment

Utils

Various helpful objects and functions

class xlsxwriter_celldsl.utils.WorkbookPair(wb: xlsxwriter.workbook.Workbook, fmt: xlsxwriter_celldsl.formats.FormatHandler)[source]

A pair used to bundle a FormatHandler and a Workbook

add_worksheet(name)[source]

Create a worksheet and bind it into a WorksheetTriplet

classmethod from_wb(wb)[source]

Bind a Workbook into a WorkbookPair

class xlsxwriter_celldsl.utils.WorksheetTriplet(wb: xlsxwriter.workbook.Workbook, ws: xlsxwriter.worksheet.Worksheet, fmt: xlsxwriter_celldsl.formats.FormatHandler)[source]

A triplet used for cell_dsl operations.

xlsxwriter_celldsl.utils.chain_rich(iterable: Iterable[WriteRichOp]) WriteRichOp[source]

Take an iterable of WriteRich segments and combine them to produce a single WriteRich operation.

xlsxwriter_celldsl.utils.col_chain(iterable: Iterable, initial_save_name: Optional[str] = None, final_save_name: Optional[str] = None, range_name: Optional[str] = None, array_name: Optional[str] = None, step=1) List[CommitTypes][source]

Iterate iterable and insert step NextRows between each command and then come back to start Perhaps also save initial location as initial_save_name and final location as final_save_name. Perhaps also make the result a named range with name range_name. Perhaps add a forward reference as well with name array_name.

xlsxwriter_celldsl.utils.row_chain(iterable: Iterable, initial_save_name: Optional[str] = None, final_save_name: Optional[str] = None, range_name: Optional[str] = None, array_name: Optional[str] = None, step=1) List[CommitTypes][source]

Iterate iterable and insert step NextCols between each command and then come back to start Perhaps also save initial location as initial_save_name and final location as final_save_name. Perhaps also make the result a named range with name range_name. Perhaps add a forward reference as well with name array_name.

xlsxwriter_celldsl.utils.segment(name, iterable: Iterable[CommitTypes]) List[CommitTypes][source]

A simple helper command to pad iterable of commands with SectionBegin and matching SectionEnd with name

Formats

Various utilities to deal with formats

class xlsxwriter_celldsl.formats.FormatDict[source]

A special variant of vanilla dictionary that implement __or__ and __hash__. Used to create and merge formats.

Examples

>>> F = FormatDict
>>> F1 = F({'font_name': 'Arial'})
>>> F2 = F({'font_size': 12})
>>> F3 = F({'font_name': 'Arial',  'font_size': 12})
>>> F1 | F2 == F3
True
>>> F2 | F1 == F3
True
>>> hash(F1 | F2) == hash(F3)
True
class xlsxwriter_celldsl.formats.FormatHandler(target: xlsxwriter.workbook.Workbook, memoized: Dict[int, xlsxwriter.format.Format] = NOTHING)[source]

This object is used to handle adding new formats when necessary. Only one should be used per Workbook.

xlsxwriter_celldsl.formats.ensure_format_uniqueness(class_)[source]

A class decorator used to verify that all formats in the decorated class are unique and use FormatDict.

Cell DSL module

class xlsxwriter_celldsl.cell_dsl.CellDSLContext(target: xlsxwriter_celldsl.utils.WorksheetTriplet, initial_row: int = 0, initial_col: int = 0, stat_receiver: Optional[xlsxwriter_celldsl.cell_dsl.StatReceiver] = None, overwrites_ok: bool = False)[source]

A context manager inside which you can perform writes and change cells in target in an arbitrary order, starting at initial_row and initial_col, even writing multiple times to a cell if overwrites_ok.

After it exits, it will execute those changes and send stats to stat_receiver.

This context manager returns an ExecutorHelper object, use commit() method to submit operations to be executed.

Parameters
  • target – Target WorksheetTriplet to apply changes with

  • stat_receiver – This is a reference to a StatReceiver object that will receive all data about visited cells and save points.

  • initial_row – Starting row, zero-based

  • initial_col – Starting column, zero-based

  • overwrites_ok – If True, it is expected that there may be several writes with different data to the same cell, which is ordinarily a sign of a bug since the result would be ambiguous. If False, overwrites raise ExecutionCellDSLError.

class xlsxwriter_celldsl.cell_dsl.ExecutorHelper(action_chain: List[xlsxwriter_celldsl.ops.classes.Command] = NOTHING)[source]

A special object that performs some preprocessing of the commands when commit is called and stores the actions to be executed in action_chain

commit(chain: Optional[Union[Iterable[Optional[Union[Iterable[CommitTypes], xlsxwriter_celldsl.ops.classes.Command, int, str, dict, xlsxwriter_celldsl.formats.FormatDict]]], xlsxwriter_celldsl.ops.classes.Command, int, str, dict, xlsxwriter_celldsl.formats.FormatDict]])[source]

Commit this chain to action_chain.

Notes

int acts like a shortcut for one or several MoveOp commands. Look at how the numbers correspond to the step direction, same as using a numpad.

7 8 9 ↖ ↑ ↗
4 5 6 ← . →
1 2 3 ↙ ↓ ↘

Examples

>>> from xlsxwriter_celldsl.ops import Write, Move, WriteRich
>>> from xlsxwriter_celldsl.formats import FormatsNamespace as F
>>> E1 = ExecutorHelper()
>>> E1.commit([
...     Write.with_data('Alpha'), 943, # Write alpha, follow by moving ↗←↘ --> →
...     [Write.with_data('Beta')], # Nested sequences are flattened
...     "Gamma", 2, # Lone strings are short forms of WriteOp.with_data(...)
...     # Dictionaries followed by a string is a short form of
...     # WriteOp.with_data(str).with_format(...)
...     F.default_font, "Delta", 2,
...     # Consecutive short forms of WriteOp are merged into WriteRich
...     F.default_font, F.center, "Epsilon ",
...     F.default_font, F.bold, " Eta",
...     F.italic, "!",
...     # Ending the short form with a format will set this cell to this format
...     F.wrapped
...     None # None is skipped
... ])
>>> E2 = ExecutorHelper()
>>> E2.commit([
...     Write.with_data('Alpha'),
...     Move.c(1).r(0), # →
...     Write.with_data('Beta'),
...     Write.with_data("Gamma"),
...     Move.r(1),
...     Write.with_data("Delta").with_format(F.default_font),
...     Move.r(1),
...     WriteRich.with_data("Epsilon ").with_format(F.default_font | F.center).then(
...         WriteRich.with_data(" Eta").with_format(F.default_font | F.bold)
...     ).then(
...         # `with_format` implicitly merges with `F.default_font`, more specifically
...         #  `Format.FALLBACK_FONT`
...         WriteRich.with_data("!").with_format(F.default_font | F.italic)
...         # Cell formats here are an exception to implicit merges
...         #  since it's not used to set the text appearance, but the cell's
...         .with_cell_format(F.wrapped)
...     )
... ])
>>> E1.action_chain == E2.action_chain
True
class xlsxwriter_celldsl.cell_dsl.StatReceiver[source]

Receiver object for stats after cell_dsl_context context finishes execution.

initial_row

Row where the execution started

Type

int

initial_col

Column where the execution started

Type

int

coord_pairs

A list of pairs, with the first element being the coordinate pair and the second being the command executed.

Type

List[Tuple[Tuple[int, int], xlsxwriter_celldsl.ops.classes.Command]]

save_points

A dictionary where the key is the name of the save point and the value is the coordinates of the cell the save point points to.

Type

Dict[str, Tuple[int, int]]

xlsxwriter_celldsl.cell_dsl.cell_dsl_context

alias of xlsxwriter_celldsl.cell_dsl.CellDSLContext