Notion Helper - v1.3.29
    Preparing search index...

    Function createBlock

    • Creates a table block.

      Parameters

      • Optionaloptions: number | Object

        Options for creating the table. Provide a number to set table_width directly, or an options object.

        • number
        • Object
          • has_column_header

            Whether the table has a column header.

          • has_row_header

            Whether the table has a row header.

          • rows

            An array of rows. Each row can be an array (strings/numbers/rich-text objects) or a table_row block.

          • table_width

            Explicit table width. When rows are supplied, the first row's cell count is used instead.

      Returns Object

      A table block object compatible with Notion's API.

      // Use with array of string arrays
      const simpleTable = block.table.createBlock({
      rows: [
      ["Header 1", "Header 2"],
      ["Row 1, Cell 1", "Row 1, Cell 2"],
      ["Row 2, Cell 1", "Row 2, Cell 2"]
      ],
      has_column_header: true
      });
      // Use with array of table_row objects
      const complexTable = block.table.createBlock({
      rows: [
      block.table_row.createBlock(["Header 1", "Header 2"]),
      block.table_row.createBlock(["Row 1, Cell 1", "Row 1, Cell 2"]),
      block.table_row.createBlock(["Row 2, Cell 1", "Row 2, Cell 2"])
      ],
      has_column_header: true,
      has_row_header: false
      });
      // Use with explicit table_width (empty table)
      // Note: Notion API will reject requests that attempt to create a table
      // without at least one row
      const emptyTable = block.table.createBlock(3);
      // Use with explicit table_width in options object
      // Note: Notion API will reject requests that attempt to create a table
      // without at least one row
      const tableWithWidth = block.table.createBlock({
      table_width: 4,
      has_column_header: true
      });