# OBJECT

## Content

The OBJECT function is used to define an object, and specify the props and values. The OBJECT function result will be an object of these props and values.

The OBJECT function can be used to create [RANGEBLOCK](/spreadjs/docs/v17/features/sparkmain/rangeblock-sparkline) sparklines.

## Syntax

`OBJECT(property1, expression1, property2, expression2, ...)`

`OBJECT(properties_range, expressions_range)`

`OBJECT(property1, expressionArray1, property2, expressionArray2, ...)`

## Arguments

The `OBJECT(property1, expression1, property2, expression2, ...)` function has four arguments:

| **Argument** | **Description** |
| -------- | ----------- |
| property1 | Refers to the first property of current object. It can be a string or a cell reference. |
| *expression1* | Refers to the first property value of current object. It can be any type value or a cell reference. |
| property2 | Refers to the second property of current object. It can be a string or a cell reference. |
| expression2 | Refers to the second property value of current object. It can be any type value or a cell reference. |

This `OBJECT(properties_range, expressions_range)` function has four arguments:

| **Argument** | **Description** |
| -------- | ----------- |
| *properties\_range1* | Refers to the first property of current object. It should be a range reference. |
| *expressions\_range1* | Refers to the first property value of current object. It should be a range reference, and the length of this range should be equal to the length of property range. |
| properties\_range2 | Refers to the second property of current object. It should be a range reference, and the length of this range should be equal to the length of first property range. |
| expressions\_range2 | Refers to the second property value of current object. It should be a range reference, and the length of this range should be equal to the length of first property range. |

The `OBJECT(property1, expressionArray1, property2, expressionArray2, ...)` function has four arguments:

| **Argument** | **Description** |
| -------- | ----------- |
| *property1* | Refers to the first property of current object. It can be a string or a cell reference. |
| *expressionArray1* | Refers to the first property value of current object. It should be an array of reference. |
| property2 | Refers to the second property of current object. It can be a string or a cell reference. |
| expressionArray2 | Refers to the second property value of current object. It should be an array of reference, and its length should be equal to the length of first property value. |

## Remarks

The OBJECT function will return CalcError if the parameters are not in key-value order and in pairs.

## Data Types

The `OBJECT(property1, expression1, property2, expression2, ...)` and `OBJECT(properties_range, expressions_range)` returns object value data types, while `OBJECT(property1, expressionArray1, property2, expressionArray2, ...)` returns object array data type.

## Examples

```JavaScript
$(document).ready(function () {
    // initializing Spread
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
    // get the activesheet
    var sheet = spread.getActiveSheet();
    // DataSource is array
    let dataSource = [
        {
            "NAME": "James Smith",
            "POSITION": "AVP",
            "OFFICE": "Fox Studios",
            "EXTN": 71,
            "START_DATE": '3/08/2008',
            "JOINING_YEAR": 2008
        }
    ];
    let colInfos = [
        { name: "NAME", displayName: "NAME", size: "2*" },
        { name: "POSITION", displayName: "POSITION", size: "*" },
        { name: "OFFICE", size: "*" },
        { name: "EXTN", size: "*" },
        { name: "START_DATE", size: 100 },
        { name: "JOINING_YEAR", size: 100 }
    ];
    // create style
    var style = new GC.Spread.Sheets.Style();
    style.cellButtons = [
        {
            imageType: GC.Spread.Sheets.ButtonImageType.dropdown,
            command: "openMultiColumn",
            useButtonStyle: true,
        }
    ];
    style.dropDowns = [
        {
            type: GC.Spread.Sheets.DropDownType.multiColumn,
            option: {
                width: 600,
                height: 150,
                dataSource: dataSource,
                bindingInfos: colInfos
            }
        }
    ];
    // set style's formatter
    style.formatter = '=PROPERTY(@, "OFFICE")';
    // set style
    sheet.setStyle(0, 1, style);
    // set text
    sheet.setText(0, 0, "DataSource is array, return data parsed to the value of property 'OFFICE'.");
    // set wordwrap
    sheet.getCell(0, 0).wordWrap(true);
    sheet.getCell(0, 1).wordWrap(true);
    // set column width
    sheet.setColumnWidth(0, 200);
    sheet.setColumnWidth(1, 400);
    // set row height
    sheet.setRowHeight(0, 70);
});
```