SpreadJS provides the Property Function, and the dot (".") operator to get properties of a JavaScript Object.
For the PROPERTY function, you can get the value of the property of an object. The object properties follow JavaScript rules and are case sensitive. You can use PROPERTY function in a formula:
=PROPERTY(dataexpression, propertypath).
The Dot Operator is a simplification of the PROPERTY function: the left value is the object or the reference to the object, the right value is the property value, which can be enclosed within quotes if it contains any invalid characters. It should be noted that Excel might throw errors with the Dot Operator.
For example:
sheet.setValue(0, 0, "User");
sheet.setValue(1, 1, "First Name");
sheet.setValue(1, 3, "Katy");
sheet.setValue(2, 1, "Age");
sheet.setValue(2, 3, 20);
sheet.setValue(3, 1, "Sex");
sheet.setValue(3, 3, "M");
sheet.setValue(4, 1, "Address");
sheet.setValue(5, 2, "Home");
sheet.setValue(5, 3, "Lodon");
sheet.setValue(6, 2, "Company");
sheet.setValue(6, 3, "China");
sheet.setFormula(9, 6, '=OBJECT(A1,OBJECT(B5,OBJECT(C6,D6,C7,D7),B2,D2,B3,D3,B4,D4))');
sheet.setFormatter(9, 6, '=@.User."First Name"'); // use dot operator in the formatter string
sheet.setFormula(9, 7, '=PROPERTY(PROPERTY(G10,"User"),"First Name")'); // "Katy"
sheet.setFormula(9, 8, '=PROPERTY(G10,"User.First Name")'); // "Katy"
sheet.setFormula(10, 8, '=PROPERTY(G10,"User.Address.Home")'); // "Lodon"
sheet.setFormula(10, 8, '=G10.User.Address.Home'); // "Lodon"
sheet.setFormula(12, 8, '=PROPERTY(G10,"Name")'); // "#N/A"
Submit and view feedback for