Copy link to clipboard
Copied
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.
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 !
Copy link to clipboard
Copied
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 )
Copy link to clipboard
Copied
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,
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
⦠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.
Copy link to clipboard
Copied
Quite!
Copy link to clipboard
Copied
Hi @Peter Kahrel
During all my attempt to script something, the far I went, which was "somehow sometime" working (half working) was the following code
var allCells = app.selection[0].cells.everyItem().getElements();
for ( var i = 0; i < allCells.length; i++)
{
if ( allCells[i].contents === '')
{
allCells[i].properties = {
topRightDiagonalLine : true
};
}
}
I will try your code which looks much better than mine. I will let you know. Thanks so much for your time!
Copy link to clipboard
Copied
Your code looks excellent! It's an entirely different approach.
You say that it wasn't always working. Do you know when and why?
Copy link to clipboard
Copied
Is there a problem with .everyItem() function in JS ? On another thread someone have problem with links not updating properly?
Copy link to clipboard
Copied
> Is there a problem with .everyItem() function in JS?
Never had a problem with it.
Copy link to clipboard
Copied
Could you define "somehow sometime" working? Does the script miss some cells and work for some? Or is it that the script doesn't work at all sometimes and does work sometimes? If it is the later option, then probably you have different kind of selections when it works and when it does not. Adding a log for allCells.length might help to debug
-Manan
Copy link to clipboard
Copied
Thank you for your message.
I was not able to find any pattern nor detect any related behavior leading to "not working". Running this script on the same selection will work most of time (maybe 90%) but, sometimes will not work or partially work. Run it again, and then it work. Maybe. Or not.
And that makes it not reliable, therefore I needed to think of a different approach.
That said, despiste have "more than good enought" computer (with a lot of RAM), I came to the idea that, maybe, in some extrem scenario, the buffer needed to execute the script was just not enough to complete or to render. As this would be related to the memory allocated to the process at a give time, it also depends of whatever the host is also doing on the background... I have no idea of what I am talking here, just an idea.
I like the log idea... except I don't know how to this (just add a log line ?). I will Google it later. To be honnest I've already given up on this code, which I was just bringing up as example of my faillure... But as all of you, whom are much more expert than me, seems to consider it ok; I will give it another chance..
Is there an official and updated documentation for script within Idesign ? I found a lot of non official litterature, websites and posts, but nothing Adobe official (and updated! I found few years old ones).
Copy link to clipboard
Copied
Hi @jeromevadon ,
the one thing I can offer is the link to the DOM (Document Object Model) description of InDesign 2023 compiled by Gregor Fellenz:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html
( But you may have already found that⦠)
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Nop, this one is much more recent than the one i had. Thank you so much !
Copy link to clipboard
Copied
I want here ot thanks all of you for the quality of your answers and feeback! This is great to see this!