How to split a table in InDesign? There is no simple way to split a table in InDesign!
By splitting a table, I mean dividing it into two tables. Say you have a table with 1000 rows. You want to turn that into two tables, A and B, where Table A will contain rows 1–500, and Table B will contain rows 501–1000.
Why might this be useful? There are plenty of reasons. Two small tables can be more manageable than one big one. (If you’re exporting a huge table to ePub, splitting it will improve performance. In fact, if you’re planning to convert your ePub to an Amazon Kindle .kpf file, no table is allowed to have more than 20,000 characters and it becomes necessary to split a large table. Which is what prompted me to write the script, by the way.)
Or perhaps you simply want to add some text between the tables.
Microsoft Word has this feature built in. Of course. Click on “Split Table”. But not InDesign.
So I Googled “Split Table in InDesign” and couldn’t find a script I was happy with.
app.cut(); selectRows(myNewTable, 1,1); app.paste();
There’s nothing really wrong with that code, but script purists will tell you to avoid using cut and paste. There is usually a better way of doing things. Why avoid cut and paste in a script? Well, when you invoke cut, you’re using the system clipboard. And it’s just possible that before the script gets to the paste() line, some other process on your computer has also invoked the clipboard, and what ends up getting pasted is not what was originally cut. Unlikely, perhaps, but why risk it?)
It’s probable that more googling would have come up with other scripts. But it’s more fun to do it yourself if you can!
So below you can download a free script that will split a table in InDesign. It’s called “Split Table Before” to make it easy to remember that on whatever row of the table you place your cursor when you run the script, the result will be that the table will be split before the cursor. The row the cursor is in will become the first row of the second table. (This is how it works in Word too.)
(1) Download and install the script as usual for InDesign scripts.
(2) Place the text cursor in a cell somewhere in a table, or select a cell, or a row.
(3) Run the script.
(4) The table will be split in two. The row that has been selected will become the first row of the second table.
(If you’re not happy with the result, a single Ctrl-Z will undo the operation of the script.)
I hope you find it useful! If you find any bugs or limitations, please leave a comment below or on the Id-Extras User Forum.
To download “Split Table Before”, fill in your name and address and it will be automatically emailed. By doing so you also agree to receive occasional emails from Id-Extras.com with interesting InDesign tips and tricks, news, and free scripts.