Copy link to clipboard
Copied
Hi All,
I have a table where I am trying to see if a particular column is empty, meaning the it does contain any text or anchored frames. I am thinking the best approach is to check each cell in the column, but if there is a shorthand way of doing it, I would appreciate any pointers. Thank you very much.
Rick
Copy link to clipboard
Copied
What do you consider 'empty'?
alert (app.selection[0].parent.columns[0].contents.join('').length);
(this is supposed to return '0' for an empty column, some other positive value otherwise). This will not work with columns that only seem to be empty (i.e., containing a single space). And sometimes the cells are empty but their shading indicates data.
Copy link to clipboard
Copied
This works fine for a column that contains more than one cell, but the join method fails for a single-cell column. This appears to be a good workaround.
<pre>
function colOrRowIsEmpty(colOrRow) {
if (colOrRow.cells.length == 1) {
if (colOrRow.contents.length == 0) {
return true;
} else {
return false;
}
} else {
if (colOrRow.contents.join("").length == 0) {
return true;
} else {
return false;
}
}
}
</pre>
Thank you very much for the generous help.
Rick
Copy link to clipboard
Copied
The one thing I did not try -- but your solution seems perfect. And it's a function, returning a boolean! Well done!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now