Spreadsheet validations
More information about methods to manage the cells validations.Documentation
Methods
The following methods are available to interact with the spreadsheet headers programmatically.| Method | Description |
|---|---|
| getValidations | Get the validations from a spreadsheet.
getValidations(): Promise<
GET /api/:guid/validations
|
| setValidations | Set or update the validations for a spreadsheet.
setValidations<
@param validations[].index - position of this validation. @param validations[].value - new validation value. POST /api/:guid/validations
|
Examples
Get a new validation object to the spreadsheet.
NodeJS
PHP
import { Client } from '@jspreadsheet/client';
// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
const client = new Client(token);
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Request data
spreadsheet.getValidations().then((data) => {
console.log(data);
});
// Not available in the PHP client library.
Set new validations for a spreadsheet.
NodeJS
PHP
import { Client } from '@jspreadsheet/client';
// Access token
const token = 'MSxlMjE2MWI5YWNjYTg2MzM4MThmN2Y4NjY0YmQzYzBlOGExMmVkZjVk';
// Spreadsheet Guid
const guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Create a new client
const client = new Client(token);
// Get the spreadsheet instance
const spreadsheet = client.getSpreadsheet(guid);
// Change validation at position 0
let validations = [{
index: 0,
value: {
range: 'Sheet1!A1:A6',
action: "warning",
criteria: "between",
type: "number",
allowBlank: false,
value: [10, 30],
format: undefined,
}
}];
// Set Data
spreadsheet.setValidations(validations).then(() => {
// It worked correctly
}).catch((err) => {
// Something went wrong
console.log(err);
});
// Not available in the PHP client library.