Export (0) Print
Expand All

TableBinding.rowCount property (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Gets the number of rows in the table, as an integer value.

Last modified: June 12, 2014

Introduced in Office.js version


Updated in Office.js version


var rowCount = bindingObj.rowCount;

The number of rows in the specified TableBinding object.

When you insert an empty table by selecting a single row in Excel 2013 and Excel Online (using Table on the Insert tab), both Office host applications create a single row of headers followed by a single blank row. However, if your app's script creates a binding for this newly inserted table (for example, by using the addFromSelectionAsync method), and then checks the value of the rowCount property, the value returned will differ depending whether the spreadsheet is open in Excel 2013 or Excel Online.

  • In Excel 2013, rowCount will return 0 (the blank row following the headers is not counted).

  • In Excel Online, rowCount will return 1 (the blank row following the headers is counted).

You can work around this difference in your script by checking if rowCount == 1, and if so, then checking if the row contains all empty strings.

In content apps for Access, for performance reasons the rowCount property always returns -1.

function showBindingRowCount() {
    Office.context.document.bindings.getByIdAsync("myBinding", function (asyncResult) {
        write("Rows: " + asyncResult.value.rowCount);
// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 

App types

Content apps, Task pane apps

Supported clients

Access app for SharePoint, Excel 2013, Excel Online, Excel 2013 SP1, Excel 2013 RT, Word 2013, Word 2013 SP1, Word 2013 RT





© 2014 Microsoft