Products

Columns and cell properties

This section covers the methods to manage the properties from a cell or a spreadsheet column.

Documentation

Methods

MethodDescription
getProperty Get the properties of one cell.
getProperty(
column: number,
row: number
): Promise<{ [property: string]: any }>

@param column - cell column.
@param row - cell row.

GET /api/:guid/properties
getProperty Get the properties of one or more columns.
getProperty(
columns?: number | number[]
): Promise<{ [columnIndex: string]: Column }>

@param columns - column(s) positions. If omitted, the properties of all columns will be returned.

GET /api/:guid/properties
setProperty Set the property of a column. All old properties are removed.
setProperty(
properties: { column: number; options: Column }[]
): Promise<void>

@param properties.[].column - column number
@param properties.[].options - properties values

POST /api/:guid/properties
setProperty Set the property of a cell. All old properties are removed.
setProperty(
properties: {
column: number;
row: number;
options?: { [property: string]: any };
}[]
): Promise<void>

@param properties[].column - x coordinate.
@param properties[].row - y coordinate.
@param properties[].options - properties values. If omitted, current settings will be removed.

POST /api/:guid/properties
updateProperty Update the properties of a column. Only reported properties are affected.
updateProperty(
properties: { column: number; options: Column }[]
): Promise<void>

@param properties.[].column - column number
@param properties.[].options - properties values

POST /api/:guid/properties/update
updateProperty Update the properties of a cell. Only reported properties are affected.
updateProperty(
properties: {
column: number;
row: number;
options: { [property: string]: any };
}[]
): Promise<void>

@param properties[].column - x coordinate.
@param properties[].row - y coordinate.
@param properties[].options - properties values.

POST /api/:guid/properties/update
resetProperties Removes all properties of a cell.
resetProperties(column: number, row: number): Promise<void>
@param column - cell column.
@param row - cell row.


Examples

Column properties

Update the column properties


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// New properties
const properties = {
    type: "checkbox",
    title: "Column A",
    width: "100px",
};

// Change the properties from the forth column
spreadsheet.setProperties(3, properties).then(() => {
    // It worked correctly
}).catch((err) => {
    // Something went wrong
    console.log(err);
});
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
$guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create the client instance
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// New properties
$properties = [ 'type' => 'checkbox', 'title' => 'Column A', 'width' => '100px' ];

// Change the properties from the forth column
$result = $spreadsheet->getColumn(3)->setProperties($properties);

// Result
print_r($result);

// {"success": 1, "message": "Updated"}

Read the properties of a column


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// Get the properties from the first column
spreadsheet.getProperties(0).then((properties) => {
    console.log(properties);
});

// {
//     type: "text",
//     width: "47",
// }
<?php
require 'vendor/autoload.php';

use jspreadsheet\Jspreadsheet;

// Access token
$token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
$guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create the client instance
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Get the properties from the first column
$result = $spreadsheet->getColumn(0)->getProperties();

// Result
print_r($result);

// {"type":"text","align":"center","width":"47","source":[],"options":[]}

Read the properties of multiple columns


NodeJS
PHP
import { Client } from '@jspreadsheet/client';

// Access token
const token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
const guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create a new client
const client = new Client(token);

// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);

// Get the properties from multiple columns
spreadsheet.getProperties([0, 1]).then((properties) => {
    console.log(properties);
});
<?php
require 'vendor/autoload.php';

use jspreadsheet/Jspreadsheet;

// Access token
$token = 'MSwzMTJmZWQzMWYyYTI1OWQ5OGVhMWYxOWNhMDNhYWY3ZTA2ZmVmMWQz';

// Spreadsheet Guid
$guid = '15eb1171-5a64-45bf-be96-f52b6125a045';

// Create the client instance
$client = new Jspreadsheet($token);

// Get the spreadsheet instance
$spreadsheet = $client->getSpreadsheet($guid);

// Get the properties from multiple columns
$result = $spreadsheet->getColumns([0,1])->getProperties();

// Result
print_r($result);