Skip to content

Class: TableCell ​

One table cell (a:tc).

Constructors ​

Constructor ​

new TableCell(tc, part, themeContext, style, rowIndex, colIndex, rels): TableCell

Parameters ​

ParameterTypeDescription
tcElement-
partPart-
themeContextThemeContextThe owning slide's theme colour context, threaded to the cell's text for Run.resolvedColor.
styleTableCellStyleContext | nullThe table's style-resolution context, for the resolvedFill style-graph fallback; null when no style resolves.
rowIndexnumberThis cell's zero-based row index in the table.
colIndexnumberThis cell's zero-based column index in its row.
relsRelationshipsThe owning slide's relationships, for resolving pictureFill's r:embed to a partname.

Returns ​

TableCell

Accessors ​

anchor ​

Get Signature ​

get anchor(): string | null

The cell's vertical text anchor (a:tcPr/@anchor): t/ctr/b (top/middle/ bottom), or null when unset (PowerPoint defaults to top).

Returns ​

string | null


anchorCtr ​

Get Signature ​

get anchorCtr(): boolean

Whether the cell's whole text block is centred horizontally within it (a:tcPr/@anchorCtr). false when unset — that is the schema default, and it is what PowerPoint writes nothing for.

Distinct from a paragraph's align, which decides where each line sits inside the text block; this decides where the block sits inside the cell.

Returns ​

boolean


borders ​

Get Signature ​

get borders(): CellBorders | null

The cell's edge borders (a:tcPr/a:lnL|lnR|lnT|lnB|lnTlToBr|lnBlToTr), or null when the cell defines none. Each present edge decodes to a CellBorder (width / dash / resolved colour + its raw token and transform list / suppressed flag); absent edges are null. Cell borders are the biggest visible table gap — a replica built only from geometry and fill draws every cell edge-to-edge with no rule, so this surfaces the per-side stroke the writer's border option emits.

Returns ​

CellBorders | null


cell3D ​

Get Signature ​

get cell3D(): CellThreeD | null

The cell's 3-D bevel (a:tcPr/a:cell3D), or null when it has none.

CT_Cell3D requires an a:bevel, so a present cell3D always reports a bevel; lightRig is null when the cell leaves the scene lighting to the renderer. Sizes are reported in points (the attributes are EMU), matching how the write option takes them.

Returns ​

CellThreeD | null


element_ ​

Get Signature ​

get element_(): Element

Escape hatch: the underlying a:tc element. After mutating it call markDirty, or save() writes the original bytes.

Returns ​

Element


fillNoFill ​

Get Signature ​

get fillNoFill(): boolean

true when the cell sets an explicit no-fill (a:tcPr/a:noFill) — a deliberately transparent cell showing the table background (or the slide) through. The cell-side counterpart of AutoShape.fillNoFill, and what noFill writes.

hasOwnFill is not this question: it is true for any EG_FillProperties child, so on its own it cannot separate a suppressed fill from a gradient or an image one — and every colour accessor (resolvedFill, fillSchemeColor) reports null for a no-fill cell exactly as it does for a cell that inherits its shading from the table style. Deriving it as "has a fill of its own, and no accessor recognises it" instead of reading it has two failure modes: it folds a:grpFill in with a:noFill, and its meaning changes silently the day a further fill kind gets an accessor. The two paint completely differently — an inherited banding colour versus nothing at all — so a consumer that cannot tell them apart paints a transparent cell in the style's shading.

Returns ​

boolean


fillSchemeColor ​

Get Signature ​

get fillSchemeColor(): string | null

The raw schemeClr token of the cell's solid fill (a:tcPr/a:solidFill/a:schemeClr/@val), e.g. accent1/bg1, or null when the fill is absent or an explicit srgbClr. The resolved literal is resolvedFill; this is the unresolved reference.

Returns ​

string | null


gradientFill ​

Get Signature ​

get gradientFill(): GradientFill | null

The cell's gradient fill (a:tcPr/a:gradFill), or null when the cell is not gradient-filled. The cell twin of Table.gradientFill, and needed for the same reason pictureFill is: resolvedFill reports null for every non-solid choice, so without this a gradient cell is indistinguishable from an unfilled one.

Returns ​

GradientFill | null


gridSpan ​

Get Signature ​

get gridSpan(): number

Number of grid columns this cell spans (a:tc/@gridSpan), default 1.

Returns ​

number


hasOwnFill ​

Get Signature ​

get hasOwnFill(): boolean

Whether the cell carries a fill of its own (a:tcPr holds an EG_FillProperties child), as opposed to inheriting one from the table style's header/banding rules.

This is the flag that disambiguates resolvedFill, which deliberately reports either — it answers "what colour does this cell render as", and both sources are valid answers to that. Anything that has to reproduce the cell rather than describe it needs to know which: baking an inherited banding colour into a copy makes the copy look right until someone changes its table style, and then nothing moves. false for a cell whose a:tcPr is empty or absent, whatever the style graph would render it as.

Returns ​

boolean


headerIds ​

Get Signature ​

get headerIds(): string[]

The @ids of the header cells that govern this cell (a:tcPr/a:headers/a:header/@val), in document order. Empty when the cell declares no header association — which is the common case, since only a complex table needs one.

Carries the same caveat as id: PowerPoint strips a:headers on save, so this is empty on any PowerPoint-saved deck. Table.firstRowHeader (a:tblPr/@firstRow) is the header marker PowerPoint does keep.

Returns ​

string[]


horzOverflow ​

Get Signature ​

get horzOverflow(): string | null

How the cell treats a glyph too wide for its text width (a:tcPr/@horzOverflow): 'clip' cuts it at the cell edge, 'overflow' lets it draw past. null when unset (PowerPoint clips). Not a wrap flag — cell text always wraps to the column width.

Returns ​

string | null


id ​

Get Signature ​

get id(): string | null

The cell's unique identifier (a:tc/@id), or null when it has none.

This is what headerIds references: a data cell names the header cells that govern it by their @id, which is how a complex table tells a screen reader what a value means. Unrelated to the shape-level p:cNvPr/@id — it is an xs:string scoped to the table, not a slide-wide numeric id.

PowerPoint does not write this and strips it on save, so it will read null on any deck PowerPoint has saved, however it was produced. It is surfaced for decks from other producers. There is deliberately no write-API counterpart — see test/read/fixtures/authoring/probe-table-cell-a11y-and-3d.ps1 for the measurement.

Returns ​

string | null


isMergeContinuation ​

Get Signature ​

get isMergeContinuation(): boolean

Whether this cell is a continuation of a merge (@hMerge or @vMerge), i.e. not the merge origin.

Returns ​

boolean


marginsEmu ​

Get Signature ​

get marginsEmu(): { bottom: number | null; left: number | null; right: number | null; top: number | null; } | null

The cell's text insets in EMU (a:tcPr/@marL/@marR/@marT/@marB), or null when the cell sets none. Each side is null when only some are set.

Returns ​

{ bottom: number | null; left: number | null; right: number | null; top: number | null; } | null


patternFill ​

Get Signature ​

get patternFill(): PatternFill | null

The cell's pattern (hatch) fill (a:tcPr/a:pattFill), or null when the cell is not pattern-filled.

Returns ​

PatternFill | null


pictureFill ​

Get Signature ​

get pictureFill(): PictureFill | null

The cell's picture (image) fill (a:tcPr/a:blipFill), or null when the cell is not image-filled. The cell counterpart of AutoShape.pictureFill: resolvedFill decodes only solid colours, so without this an image-filled cell is indistinguishable from an empty one. Carries the embedded image (PictureFill.relId/PictureFill.partName) plus the stretch/tile geometry; PictureFill.partName needs the owning slide's relationships, which a Table built without them cannot supply.

Returns ​

PictureFill | null


resolvedFill ​

Get Signature ​

get resolvedFill(): ResolvedColor | null

The cell's solid fill resolved against the table's theme colour context to a literal hex — the table-cell counterpart of AutoShape.resolvedFill. The cell's own a:tcPr/a:solidFill wins; when the cell defines none, this falls back to the table style graph (the firstRow/banded/wholeTbl shading the a:tableStyleId supplies — see Table.resolvedStyle), so a styled cell with an empty a:tcPr reports the colour PowerPoint actually renders rather than null.

A cell that carries some other fill choice (a:blipFill/a:gradFill/ a:pattFill/a:noFill) overrides the style graph in PowerPoint, so this reports null for one rather than falling through to the inherited shading — the same guard AutoShape.resolvedFill applies to the style matrix. Read pictureFill for an image-filled cell. Also null when neither source yields a solid colour (an unmapped token, an explicit style a:noFill). The returned ResolvedColor carries effectiveHex (the base colour with its lumMod/lumOff/… transforms applied) — read that for the final colour.

Returns ​

ResolvedColor | null


rowSpan ​

Get Signature ​

get rowSpan(): number

Number of rows this cell spans (a:tc/@rowSpan), default 1.

Returns ​

number


text ​

Get Signature ​

get text(): string

The cell's text, paragraphs joined by \n.

Returns ​

string

Set Signature ​

set text(value): void

Replace the cell's text with a single paragraph and run, preserving the formatting (a:rPr) of the cell's first existing run when there is one. For finer control (multiple runs, per-run formatting), edit textFrame.paragraphs[].runs[] directly.

Parameters ​
ParameterType
valuestring
Returns ​

void


textFrame ​

Get Signature ​

get textFrame(): TextFrame | null

The cell's text frame (a:txBody); null only if the cell has none (non-conformant).

A run that sets nothing of its own resolves the way PowerPoint paints it (test/read/fixtures/table-text-inheritance.pptx). Its colour, face, bold and italic come first from the table style's text style for the cell's region, and a colour or face no part states is the theme's tx1 and minor font, with no table style at all as much as with one. Below that, the chain a text box's runs walk bottoms out in the slide master's p:otherStyle rather than in p:defaultTextStyle, which cell text never reads. So size comes from p:otherStyle, and so do bold and italic where the table style says nothing.

Returns ​

TextFrame | null


verticalText ​

Get Signature ​

get verticalText(): string | null

The cell's text direction (a:tcPr/@vert), e.g. vert270 for a bottom-to-top vertical label, or null for default horizontal text.

Returns ​

string | null

Methods ​

markDirty() ​

markDirty(): void

Mark the owning part dirty so save() reserializes it. Call after mutating element_.

Returns ​

void


noFill() ​

noFill(): void

Write an explicit <a:noFill/> on the cell — a transparent cell that shows the table background (or the slide) through. Distinct from setFillColor(null), which removes the fill and lets the table style's shading apply again.

Returns ​

void


setAnchor() ​

setAnchor(value): void

Set (or clear) the cell's vertical text anchor (a:tcPr/@anchor). null removes the attribute, leaving PowerPoint's default of top.

Parameters ​

ParameterType
valuestring | null

Returns ​

void

Throws ​

when the value is outside ST_TextAnchoringType


setAnchorCtr() ​

setAnchorCtr(value): void

Centre the cell's text block horizontally, or stop doing so (a:tcPr/@anchorCtr). false removes the attribute rather than writing "0", since false is the schema default and the two are indistinguishable to a renderer.

Parameters ​

ParameterType
valueboolean

Returns ​

void


setBorder() ​

setBorder(edge, border): void

Set (or clear) one of the cell's six borders — the four edges and the two diagonals.

null removes the element entirely, which is "inherit", and is a different thing from { noFill: true }, which writes an explicit no-border and suppresses whatever would otherwise be inherited. The element is inserted at its schema position rather than appended: CT_TableCellProperties is a sequence, and an out-of-order a:tcPr is reported by PowerPoint as a corrupt file rather than as a bad edit.

Colour is either color (6-hex, # optional) or schemeColor (a theme token); giving both prefers the token, matching how the read side reports them.

Parameters ​

ParameterType
edge"left" | "top" | "bottom" | "right" | "tlToBr" | "blToTr"
borderTableCellBorderEdit | null

Returns ​

void

Throws ​

when the width or colour cannot be written


setFillColor() ​

setFillColor(color): void

Replace the cell's fill with a solid colour (a:tcPr/a:solidFill), or clear it.

null removes the a:solidFill and lets the cell inherit from the table style again. That is not the same as noFill, which writes an explicit a:noFill and so suppresses the inherited shading. Any competing fill choice (a:gradFill, a:blipFill, …) is dropped first — EG_FillProperties admits one.

Parameters ​

ParameterType
colorstring | null

Returns ​

void

Throws ​

when color is not a 6-digit hex string


setFillSchemeColor() ​

setFillSchemeColor(token): void

Replace the cell's fill with a theme colour token (a:solidFill/a:schemeClr/@val), or clear it. Preferred over setFillColor when the deck's theme should keep driving the colour.

Parameters ​

ParameterType
tokenstring | null

Returns ​

void


setHorzOverflow() ​

setHorzOverflow(value): void

Set (or clear) a:tcPr/@horzOverflow — what a single glyph too wide for the cell does. null removes the attribute; so does 'clip' in effect, since it is the schema default, but the attribute is still written as asked.

Parameters ​

ParameterType
valuestring | null

Returns ​

void

Throws ​

when the value is outside ST_TextHorzOverflowType


setMarginsEmu() ​

setMarginsEmu(margins): void

Set the cell's text insets in EMU (a:tcPr/@marL/@marR/@marT/@marB).

Partial: only the sides named are touched, so { left: 0 } flushes the text left and leaves the other three alone. A side given as null has its attribute removed, which returns it to the schema default (91440 EMU left/right, 45720 top/bottom) — not to zero. Pass {} to change nothing.

Parameters ​

ParameterType
margins{ bottom?: number | null; left?: number | null; right?: number | null; top?: number | null; }
margins.bottom?number | null
margins.left?number | null
margins.right?number | null
margins.top?number | null

Returns ​

void

Throws ​

when a value is not a finite number


setVerticalText() ​

setVerticalText(value): void

Set (or clear) the cell's text direction (a:tcPr/@vert), e.g. 'vert270'. null removes the attribute, leaving the default horizontal text.

Parameters ​

ParameterType
valuestring | null

Returns ​

void

Throws ​

when the value is outside ST_TextVerticalType