Link cell to Shape

Posted by: sdorner on 26 August 2026, 3:00 pm EST

  • Posted 26 August 2026, 3:00 pm EST

    In Excel I can link a shape to a cell. This is a great way to design dashboards in Excel. Example, in cell G4 I have a formula =PI(). Then I draw a shape and can set the formula for the Rectangle =$G$4 and the shape displays 3.1416 (i.e. what is shown in G4). I can now drag the shape around and the formula stays with the shape.

    Is this possible in SpreadJS. If not, can it be added in a future release.

  • Posted 27 August 2026, 6:08 am EST

    Hi,

    Yes, this is possible in SpreadJS — no future release needed.

    You can link any shape property, including its text, to a cell using setFormula(). For your scenario:

    var sheet = spread.getActiveSheet();
    sheet.setFormula(3, 6, "=PI()"); // G4
    
    var rect = sheet.shapes.add("rect1", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 50, 150, 80);
    rect.setFormula("text", "=Sheet1!G4");

    The shape’s displayed text will now track whatever G4 evaluates to (3.14159…), and the link stays with the shape when you drag it around, just like Excel’s shape-to-cell linking.

    A few things worth knowing:

    This isn’t limited to text — setFormula() works on most shape properties (position, size, fill color, border, font, etc.), so you can drive an entire dashboard shape’s appearance from cell values.

    If the formula you link to text is a plain cell reference (e.g. =Sheet1!G4), that link is preserved when exporting to Excel.

    This works for both built-in shapes and custom shapes.

    You can see a live example here: https://developer.mescius.com/spreadjs/demos/features/shapes/shape-with-formula/purejs

    Docs reference (Shape Property Formulas):

    https://developer.mescius.com/spreadjs/docs/features/UnderstandingShapes/AddingShapeswithFormulas

    Regards,

    Priyam

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels