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

Method insert_textbox

xlsxwriter/worksheet.py:1646–1697  ·  view source on GitHub ↗

Insert an textbox with its top-left corner in a worksheet cell. Args: row: The cell row (zero indexed). col: The cell column (zero indexed). text: The text for the textbox. options: Textbox options. Returns:

(
        self, row: int, col: int, text: str, options: Optional[Dict[str, Any]] = None
    )

Source from the content-addressed store, hash-verified

1644
1645 @convert_cell_args
1646 def insert_textbox(
1647 self, row: int, col: int, text: str, options: Optional[Dict[str, Any]] = None
1648 ) -> Literal[0, -1]:
1649 """
1650 Insert an textbox with its top-left corner in a worksheet cell.
1651
1652 Args:
1653 row: The cell row (zero indexed).
1654 col: The cell column (zero indexed).
1655 text: The text for the textbox.
1656 options: Textbox options.
1657
1658 Returns:
1659 0: Success.
1660 -1: Row or column is out of worksheet bounds.
1661
1662 """
1663 # Check insert (row, col) without storing.
1664 if self._check_dimensions(row, col, True, True):
1665 warn(f"Cannot insert textbox at ({row}, {col}).")
1666 return -1
1667
1668 if text is None:
1669 text = ""
1670
1671 if options is None:
1672 options = {}
1673
1674 x_offset = options.get("x_offset", 0)
1675 y_offset = options.get("y_offset", 0)
1676 x_scale = options.get("x_scale", 1)
1677 y_scale = options.get("y_scale", 1)
1678 anchor = options.get("object_position", 1)
1679 description = options.get("description", None)
1680 decorative = options.get("decorative", False)
1681
1682 self.shapes.append(
1683 [
1684 row,
1685 col,
1686 x_offset,
1687 y_offset,
1688 x_scale,
1689 y_scale,
1690 text,
1691 anchor,
1692 options,
1693 description,
1694 decorative,
1695 ]
1696 )
1697 return 0
1698
1699 @convert_cell_args
1700 def insert_chart(

Callers 15

test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80
test_create_fileMethod · 0.80

Calls 2

_check_dimensionsMethod · 0.95
getMethod · 0.80

Tested by 15

test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64
test_create_fileMethod · 0.64