Spreadsheet validations
More information about methods to manage the cells validations.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”The following methods are available to interact with the spreadsheet headers programmatically.
| Method | Description |
|---|---|
| getValidations | Get the validations from a spreadsheet. Jspreadsheet getValidations(): Promise<Validation[]> GET /api/:guid/validations |
| setValidations | Set or update the validations for a spreadsheet. @param validations[].index - position of this validation. @param validations[].value - new validation value. Jspreadsheet setValidations(validations: { index: number; value: Validation; }[]): Promise<void> POST /api/:guid/validations |
Examples
Section titled “Examples”Get a new validation object to the spreadsheet.
Section titled “Get a new validation object to the spreadsheet.”import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Request dataspreadsheet.getValidations().then((data) => { console.log(data);});Set new validations for a spreadsheet.
Section titled “Set new validations for a spreadsheet.”import { Client } from "@intrasheets/client";
// Create a new clientconst client = new Client({ // API Server baseUrl: "http://localhost:8009/api", // Your authentication token token: "eyJhbGciOiJIUzUxMiIsInR5cCJ9.eyJkb21haW4iOiJsb2NhbGhvc3Q6ODAPQSJ9.Xr2Ir2-zEc_tqV5y6i",});
// Spreadsheet Guidconst guid = '79b45919-c751-4e2b-a49a-6c1286e2fc03';
// Get the spreadsheet instanceconst spreadsheet = client.getSpreadsheet(guid);
// Change validation at position 0let validations = [{ index: 0, value: { range: 'Sheet1!A1:A6', action: "warning", criteria: "between", type: "number", allowBlank: false, value: [10, 30], format: undefined, }}];// Set Dataspreadsheet.setValidations(validations).then(() => { // It worked correctly}).catch((err) => { // Something went wrong console.log(err);});