Skip to content

Shapes

Insert preset geometry shapes into worksheets. Shapes are anchored between two cells (top-left and bottom-right) and can include text, fill colors, and line styling.

Supported Shape Types

TypePreset NameDescription
rectrectRectangle
roundRectroundRectRounded rectangle
ellipseellipseEllipse / circle
triangletriangleTriangle
diamonddiamondDiamond
pentagonpentagonPentagon
hexagonhexagonHexagon
octagonoctagonOctagon
rightArrowrightArrowRight arrow
leftArrowleftArrowLeft arrow
upArrowupArrowUp arrow
downArrowdownArrowDown arrow
leftRightArrowleftRightArrowLeft-right arrow
upDownArrowupDownArrowUp-down arrow
star4star44-point star
star5star55-point star
star6star66-point star
flowChartProcessflowChartProcessFlowchart process
flowChartDecisionflowChartDecisionFlowchart decision
flowChartTerminatorflowChartTerminatorFlowchart terminator
flowChartDataflowChartInputOutputFlowchart data (I/O)
heartheartHeart
lightninglightningBoltLightning bolt
plusmathPlusPlus sign
minusmathMinusMinus sign
cloudcloudCloud
callout1wedgeRectCalloutRectangular callout
callout2wedgeRoundRectCalloutRounded rectangular callout

Shape type strings are case-insensitive. Aliases like "rectangle" for "rect", "circle" for "ellipse", and "oval" for "ellipse" are also accepted.

add_shape / addShape

Add a shape to a sheet, anchored between two cells.

Rust:

rust
use sheetkit::{ShapeConfig, ShapeType};

let config = ShapeConfig {
    shape_type: ShapeType::RoundRect,
    from_cell: "B2".to_string(),
    to_cell: "F10".to_string(),
    text: Some("Hello World".to_string()),
    fill_color: Some("4472C4".to_string()),
    line_color: Some("2F528F".to_string()),
    line_width: Some(1.5),
};
wb.add_shape("Sheet1", &config)?;

TypeScript:

typescript
wb.addShape("Sheet1", {
    shapeType: "roundRect",
    fromCell: "B2",
    toCell: "F10",
    text: "Hello World",
    fillColor: "4472C4",
    lineColor: "2F528F",
    lineWidth: 1.5,
});

ShapeConfig

FieldRust TypeTS TypeRequiredDescription
shape_type / shapeTypeShapeTypestringYesPreset geometry type (see table above)
from_cell / fromCellStringstringYesTop-left anchor cell (e.g., "B2")
to_cell / toCellStringstringYesBottom-right anchor cell (e.g., "F10")
textOption<String>string?NoText content displayed inside the shape
fill_color / fillColorOption<String>string?NoFill color as hex (e.g., "4472C4")
line_color / lineColorOption<String>string?NoLine/border color as hex (e.g., "2F528F")
line_width / lineWidthOption<f64>number?NoLine width in points

Shapes do not require external relationship entries (unlike charts and images). They are embedded directly in the drawing XML.

Notes

  • Shapes use the OOXML <xdr:sp> element inside a <xdr:twoCellAnchor>.
  • Fill and line colors use sRGB hex values (6 characters, no # prefix).
  • Line width is specified in points (1 point = 12700 EMU).
  • Multiple shapes can be added to the same sheet.
  • Shapes can coexist with charts and images on the same sheet.

Released under the MIT / Apache-2.0 License.