Managing Sheet with APIs

SheetAPI.updateCells



updateCells( hd, cellObjs, callback, scope )

SheetAPI.updateCells method is used to update a list of cells for the passed sheet object.

Parameters The handle information of the Sheet application your created.

An array of the cells need to be updated, every item of this array will be an object. Each object includes the following items:

NameDescription
sheetThe defined sheet id of the cell you want to update, if ignore, the default is currently active tab id
rowThe row index of the cell you want to update.
colThe column index of the cell you want to update.
jsonjson property contains all the style and setting of the cell
applyWayCould be ['apply', 'applyIf', 'clear'], default to 'clear'. 'apply' means it will use the property in json to replace these propety in the current cell; 'applyIf' means it will use the property in json to add to the current cell if the current cell doesn't have that property; 'clear' means clear all the property of the cell first and then apply json to this cell
The callback function which will be called after the file is loaded. The scope for the callback function.

Example code


	var cells = [];
	cells.push({
	      sheet: 1,
	      row: 1,
	      col: 1,
	      json: { data: '=B1+B2', cal: true}
	});
	cells.push({
	      sheet: 1,	
	      row: 2,
	      col: 1,
	      json: { data: 500}
	});
	cells.push({
	      sheet: 1,
	      row: 3,
	      col: 1,
	      json: { data: 123.45, fm: "money|$|2|none"}
	});
    
	SHEET_API.updateCells(SHEET_API_HD, cells);
    

The above method will update 3 cells. Cells is an array of cell and every item of this array will be an object, which like this:

{
        sheet:1,   // Option: the defined sheet id of the cell you want to update, if ignore, the default is currently active tab id
        row:1,     // the row index of the cell you want to update
        col:1,     // the column index of the cell you want to update
        json:{     // json property contains all the style and setting of the cell
            data:"ABC",     // the data in this cell, it can be a calculate such as "=SUM(A1,B1)"
            bgc: 'black',   // the background-color of this cell
            color: 'white'  // the font-color of this cell
            ...
        },
        applyWay: 'clear'
}

To see detail definition for the cell properties, please go to page: Cell Properties Definition

 

 


Copyright © FeyaSoft Inc. All rights reserved.