docx
    Preparing search index...

    Class TableCell

    Represents a table cell in a WordprocessingML document.

    A table cell is the basic unit of content within a table. Each cell can contain paragraphs, nested tables, or other block-level content. Cells must always end with a paragraph element.

    Reference: http://officeopenxml.com/WPtableCell.php

    <xsd:complexType name="CT_Tc">
    <xsd:sequence>
    <xsd:element name="tcPr" type="CT_TcPr" minOccurs="0" maxOccurs="1"/>
    <xsd:group ref="EG_BlockLevelElts" minOccurs="1" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="s:ST_String" use="optional"/>
    </xsd:complexType>
    new TableCell({
    children: [new Paragraph("Cell content")],
    width: { size: 3000, type: WidthType.DXA },
    });

    Hierarchy (View Summary)

    Index
    options: Omit<Omit<ITableCellOptions, "revision">, "shading" | "borders"> & {
        borders?: {
            bottom?: Omit<IBorderOptions, "color"> & { color?: string };
            end?: Omit<IBorderOptions, "color"> & { color?: string };
            left?: Omit<IBorderOptions, "color"> & { color?: string };
            right?: Omit<IBorderOptions, "color"> & { color?: string };
            start?: Omit<IBorderOptions, "color"> & { color?: string };
            top?: Omit<IBorderOptions, "color"> & { color?: string };
        };
        shading?: Omit<IShadingAttributesProperties, "fill" | "color"> & {
            color?: string;
            fill?: string;
        };
    } & {
        revision?: Omit<
            ITableCellPropertiesOptionsBase & IChangedAttributesProperties,
            "shading"
            | "borders",
        > & {
            borders?: {
                bottom?: Omit<IBorderOptions, "color"> & { color?: (...) | (...) };
                end?: Omit<IBorderOptions, "color"> & { color?: (...) | (...) };
                left?: Omit<IBorderOptions, "color"> & { color?: (...) | (...) };
                right?: Omit<IBorderOptions, "color"> & { color?: (...) | (...) };
                start?: Omit<IBorderOptions, "color"> & { color?: (...) | (...) };
                top?: Omit<IBorderOptions, "color"> & { color?: (...) | (...) };
            };
            shading?: Omit<IShadingAttributesProperties, "fill" | "color"> & {
                color?: string;
                fill?: string;
            };
        };
    }

    The options the cell was created with.

    Its borders and shading are declared with hex colors, as they were before they took colors of the document's theme, so that code reading them still compiles. A cell given a theme color has it here as it was given.

    • get writtenAs(): readonly BaseXmlComponent[] | undefined
      Internal

      The components written in this one's place, one after another, when it can't be written as a single element, such as a run with another run in its children. Undefined when it is written as itself.

      Returns readonly BaseXmlComponent[] | undefined

    • Prepares this component and its children for XML serialization.

      This method is called by the Formatter to convert the component tree into an object structure compatible with the xml library (https://www.npmjs.com/package/xml). It recursively processes all children and handles special cases like attribute-only elements and empty elements.

      The method can be overridden by subclasses to customize XML representation or execute side effects during serialization (e.g., creating relationships).

      Parameters

      • context: IContext

        The serialization context containing document state

      Returns IXmlableObject | undefined

      The XML-serializable object, or undefined to exclude from output

      // Override to add custom serialization logic
      prepForXml(context: IContext): IXmlableObject | undefined {
      // Custom logic here
      return super.prepForXml(context);
      }
    • Internal

      Gives the cell, unless it has a width of its own, the width of the table's columns it spans, in twips.

      Parameters

      • twips: number

      Returns void