Delete Empty Rows and Columns
This script provides the ability to delete empty rows and columns, unmerge all cells, set all cells to auto-grow, and specify the table width of selected tables or all tables in a document.
Delete Empty Rows and Columns consists of a single DeleteEmptyRowsAndColumns.jsx file. One good tutorial on how to copy this into the correct folder on your computer can be found at https://www.danrodney.com/scripts/directions-installingscripts.html
Using the script
Display InDesign’s Scripts panel on the screen (Window > Utilities > Scripts). Optionally select one or more tables, and double-click the DeleteEmptyRowsAndColumns.jsx script in the Scripts panel.
The Scope section lets you specify that the script applies to all the tables in the document, or just the selected tables. Keep in mind that InDesign tables are “inline” objects. For this script, the character that holds the table(s) must be selected with the Type tool.
The Rows and Columns section lets you specify if you want to delete empty rows, empty columns, or both.
Selecting the Ignore data-merge markers and white space option will consider a cell “empty” if it only contains data-merge markers, spaces, tabs, etc.
Selecting the Unmerge all cells option will unmerge any horizontally or vertically merged cells.
Selecting the Set all cells to auto-grow option will change the row height of all rows from Exactly to At Least so that they automatically grow in height to accommodate their contents. This is often the preferred setting for many tables.
The Set width of all tables option allows you to specify a width for the tables. Specify a measurement system using any of the common InDesign specifiers, such as i, in, pt, p, cm, mm, etc.
The effects of the script are completely undo-able via Edit > Undo.