cancel
Showing results for 
Search instead for 
Did you mean: 

Find the number of rows and columns in a table

Former Member
0 Kudos

Hi all,

I need to find the total number of rows and columns in a particular table. Could you please assist, how to do the same.

Cheers

Umang

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I need to find the total number of rows and columns in a particular table.

Total no of Rows

Use the following code in your action handler or method



wdContext.node<YourNodeName>().size()
NodeName is the name of the node bound to the table.

Ex:
In the following case node name is "Orders"
int x = wdContext.nodeOrders().size();

To the find the columns in the table use the following method in the wdDomodify method of your view



//Your table need to be changed to that of your table
if(firstTime)
{
IWDTable table = (IWDTable)view.getElement("<YourTable>");
                  //Use the following code in older versions
	  int x = table.getColumns().length;
                   //Use the following code in latest versions
	  int x= table.getGroupedColumns().length;
//If you want to store this for later use
//Assuming ColCount is an attribute of type int
wdContext.currentContextElement().setColCount(x);

}
You can store x in a attribute and use it later

Regards

Ayyapparaj

Former Member
0 Kudos

And why not just IWDTable.numberOf...?

Armin

Answers (1)

Answers (1)

nikhil_bose
Active Contributor
0 Kudos

Number of Rows:

wdContext.node<YourTableNode>.size();

you can use IWDTable methods inside wdDoModifyView() to get row and column counts

nikhil