docx
    Preparing search index...

    Type Alias TableRowsPatch

    Patch definition that repeats the rows of a table in the template, once for each row of data, so a table can be designed in Word and filled in with any number of rows.

    The rows it repeats are those that hold its fields: placeholders made of the patch's key, a dot and the field's name, such as {{items.name}} and {{items.price}} for the patch items. Each copy's fields are patched with a row's patches, by their field's name, and the other rows of the table, such as its header, are kept as they are. Rows next to each other are repeated together, such as a row for an item and a row for its notes.

    A field that a row has no patch for is left empty. With no rows, the rows are removed, and so is a table left with none. The other patches are applied after the rows are repeated, so a placeholder of theirs in a repeated row, such as {{currency}}, is patched in every copy.

    const text = (value: string): IPatch => ({ type: PatchType.PARAGRAPH, children: [new TextRun(value)] });

    await patchDocument({
    outputType: "nodebuffer",
    data: template,
    patches: {
    items: {
    type: PatchType.TABLE_ROWS,
    rows: [
    { name: text("Apples"), price: text("1.20") },
    { name: text("Pears"), price: text("0.90") },
    ],
    },
    },
    });
    type TableRowsPatch = {
        rows: readonly Readonly<
            Record<string, IPatch | TableRowsPatch | undefined>,
        >[];
        type: typeof TABLE_ROWS;
    }
    Index
    rows: readonly Readonly<Record<string, IPatch | TableRowsPatch | undefined>>[]

    The patches for each copy of the rows, by the name of the field they patch, such as name for {{items.name}}. A field's patch can repeat rows of a table in the copy in turn, whose fields are then such as {{items.parts.name}}. When those fields are in the copy's own row, rather than in a table in it, the row is repeated for each part, with its item's fields, and an item without parts has no row

    type: typeof TABLE_ROWS

    Indicates this patch repeats the rows of a table