Skip to content

Tables

Place data tables on Present-mode sheets. place takes plain string rows and creates one table shape — the same shape the Present canvas creates when a spreadsheet table is pasted (the Program-mode / Google Sheets / Excel paste flow). Accessed via snaptrude.presentation.tables.

The method is a host API call that returns a Promise and writes to the Present canvas.

At a glance

MethodWhat it doesMutates?
place(sheetId, table, options?)Place string rows as a table shape on a sheet

Present mode required

place requires Present mode (the documentation editor) to be open and throws otherwise.

Functions

place(sheetId, table, options?)

Place a table on a sheet. Creates one table shape from table.rows and returns the created shape as a canvas-shape record (the same record shape placedViews.getShape reads back). Cells are plain strings; rows may be ragged (each row needs at least one cell), capped at 10000 cells total. The shape is nested under the sheet frame so it moves with the sheet. One undo step.

  • Parameters:
    • sheetId: string — the sheet to place the table on
    • table.rows: string[][] — table cells as string rows (non-empty; ≤ 10000 cells total)
    • options.position: { x: number; y: number } | undefined — sheet-local position, relative to the sheet's top-left in canvas units (the same convention as annotate.*); when omitted the table lands where the paste flow would auto-place it — the center of the current viewport
  • Returns: PluginCanvasShape — the created table shape record (type is "paste_table"; see Placed views → PluginCanvasShape).
  • Throws: If Present mode is not open, the sheet id is invalid, or the table is empty / exceeds the 10000-cell cap.
ts
const { sheets } = await snaptrude.presentation.sheets.list();
const shape = await snaptrude.presentation.tables.place(
  sheets[0].id,
  {
    rows: [
      ["Room", "Area"],
      ["Kitchen", "12.4 m²"],
      ["Living", "28.0 m²"]
    ]
  },
  { position: { x: 40, y: 40 } }
);
console.log(shape.shapeId, shape.sheetId); // nested under the sheet frame

Errors

Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:

CodeThrown byWhendetails
VALIDATIONplaceEmpty rows, an empty row, or more than 10000 cells total
PRECONDITION_FAILEDplacePresent mode is not open
HANDLE_INVALIDplacesheetId is unknown or is not a sheet (frame)
OPERATION_FAILEDplaceThe paste flow produced no table shape