Skip to main content
jeromevadon
Known Participant
November 15, 2022
Question

Table's cells + GREP/Regex + diagonal lines

  • November 15, 2022
  • 3 replies
  • 2012 views

Hello everyone.
I have that recuring problem of having huge tables, sometimes with 100+ cols and rows (litterally thousands of cells) and I need to "strike" the empty ones... Doing this by hand is tedious and as empty cells can be anywhere in table, alone or in a group, we are taking about some hours lost in Indesign void for nothing.

  • I know that you can easily add a diagonal line to a cell (or many at once if you have many selected) by using the "Table > Cell Options > Diagonal Lines" option upon a selection.
  • I know to REGEX my way of selection to only select the empty cells (with ^\Z), but the GREP search window does not seems to offer any cell options (like "diagonal lines") nor any cell style for that matter (which  forbid any kind of workaround using that way).

 

Does any one ever had this need and know a realistic way of processing this? I've tried with GREP/Regex, but I am stuck at the manipulation needed, and I've tried through the scripting way, be here to, I find very hard to get any type of clear documentation of cells caracteristic and "righ direction" hint. And I am not that good with scripting (btw if you have a really deep and good documentation, like a serious one, feel free to share. I found several but nothing like a full documentation, and far to be consistent or official...)

 

Thank you !

This topic has been closed for replies.

3 replies

jeromevadon
Known Participant
November 17, 2022

I want here ot thanks all of you for the quality of your answers and feeback! This is great to see this!

Community Expert
November 15, 2022

@jeromevadon 

 

You'll need a script for this, you won't be able to do it in the interface (not reasonably, anyway). The script gets all the empty texts/stories using the GREP expression that you already use, then it cycles through them and applies a cell style to the cells that contain those empty strings. The cell style, which sets the diagonal line, as Uwe mentions, should be present. Here goes:

app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '^\\Z';
cellStyle = app.documents[0].cellStyles.item ('diagonalLine');
empties = app.documents[0].findGrep();
for (i = 0; i < empties.length; i++) {
  if (empties[i].parent instanceof Cell) {
    empties[i].parent.appliedCellStyle = cellStyle;
  }
}

Peter

pixxxelschubser
Community Expert
November 15, 2022
quote

… The cell style, which sets the diagonal line, … should be present …

 

By @Peter Kahrel

 

… and either named with the name "diagonalLine" (used in the script) or the name in Peter's script is changed to match the name of your cell style.

 




Community Expert
November 15, 2022

Quite!

Community Expert
November 15, 2022

Hi @jeromevadon ,

don't know how exactly you'll define an empty cell, but if you only aim at empty text cells, you could ask for its contents value. If that is an empty string, you could use all the properties for diagonalLine to draw one. Or apply a cell style that has the diagonal line defined in the manner you need it.

 

Basically it's this when a cell is selected and a cell style with name "diagonalLine" is defined:

var myCell = app.selection[0];
var digonalLineCellStyle = app.documents[0].cellStyles.itemByName("digonalLine");

if ( myCell.contents == "" )
{ myCell.appliedCellStyle = digonalLineCellStyle };

 

Regards,
Uwe Laubender
( Adobe Community Expert )

jeromevadon
Known Participant
November 15, 2022

Hi @Laubender,

Thank you very much for your message.
This sounds to be a very valuable way to solve my problem. I will try and test it!

Regards,