getInnerSizeInPX();
The getInnerSizeInPX method gets size (in pixels) of visible part for a given range.
This method returns a JSON object with the following properties: width and height of the visible part of the range.
Sizes of the visible range part are based on sizes of visible cells included in this range.
To execute the example, the HTML page must contain the TabSheet component named tabSheet (see Example of Creating the TabSheet Component). Get total size of the B1:F4 range and size of its visible part, given in pixels and in number of rows and columns included into the range:
// Determine the B1:F4 range var range = tabSheet.getRange(1, 1, 5, 4); // Get size of visible range part in pixels var size = range.getInnerSizeInPX(); console.log("Width of visible range in pixels: " + size.width + ", Height: " + size.height); // Determine total range size var fullSize = range.getInnerVirtualSizeInPX(); console.log("Total range width in pixels: " + fullSize.width + ", Height: " + fullSize.height); /* Get range size expressed in the number of visible rows and columns within the range */ var sizeInCells = range.getSizeInCells(); var msg = "Range width in the number of visible columns: " + sizeInCells.columnsCount; msg += ", Height in the number of visible rows: " + sizeInCells.rowsCount; console.log(msg); // get range size expressed in the total number of cells var sizeInVCells = range.getSizeInVirtualCells(); msg = "Range width in the total number of columns: " + sizeInVCells.columnsCount; msg += ", Height in the total number of rows: " + sizeInVCells.rowsCount; console.log(msg);
After executing the example the browser console shows total size of the B1:F4 range and size of its visible part, given in pixels and in columns and rows:
Width of visible range in pixels: 100, height: 50
Total range width in pixels: 500, height: 200
Range width in visible columns: 3, height in visible rows: 3
Range width, total number of columns: 5, height, total number of rows: 4
See also: