MCPcopy
hub / github.com/jmcnamara/XlsxWriter / _write_formula

Method _write_formula

xlsxwriter/worksheet.py:762–799  ·  view source on GitHub ↗
(
        self,
        row: int,
        col: int,
        formula: str,
        cell_format: Optional[Format] = None,
        value=0,
    )

Source from the content-addressed store, hash-verified

760
761 # Undecorated version of write_formula().
762 def _write_formula(
763 self,
764 row: int,
765 col: int,
766 formula: str,
767 cell_format: Optional[Format] = None,
768 value=0,
769 ) -> Literal[0, -1, -2]:
770 if self._check_dimensions(row, col):
771 return -1
772
773 if formula is None or formula == "":
774 warn("Formula can't be None or empty")
775 return -1
776
777 # Check for dynamic array functions.
778 if re_dynamic_function.search(formula):
779 return self.write_dynamic_array_formula(
780 row, col, row, col, formula, cell_format, value
781 )
782
783 # Hand off array formulas.
784 if formula.startswith("{") and formula.endswith("}"):
785 return self._write_array_formula(
786 row, col, row, col, formula, cell_format, value
787 )
788
789 # Modify the formula string, as needed.
790 formula = self._prepare_formula(formula)
791
792 # Write previous row if in in-line string constant_memory mode.
793 if self.constant_memory and row > self.previous_row:
794 self._write_single_row(row)
795
796 # Store the cell data in the worksheet data table.
797 self.table[row][col] = CellFormulaTuple(formula, cell_format, value)
798
799 return 0
800
801 @convert_range_args
802 def write_array_formula(

Callers 4

_write_numberMethod · 0.95
write_formulaMethod · 0.95
add_tableMethod · 0.95

Calls 5

_check_dimensionsMethod · 0.95
_write_array_formulaMethod · 0.95
_prepare_formulaMethod · 0.95
_write_single_rowMethod · 0.95

Tested by

no test coverage detected