Copy link to clipboard
Copied
Hallo zusammen,
nachdem mir hier in dieser Diskussion super geholfen wurde habe ich eine neue Anfrage:
Ich habe oftmals Tabellen mit 1-3000 Zeilen. Die Zellenhöhe ist fix definiert und wird für die gesamte Tabelle angepasst.
Wenn ich nun den Text in die Tabelle einlade, gibt es etliche Zelleninhalte, die Überlauftext haben, der nciht angezeigt wird (nur mit dem roten Punkt am Ende der Zelle).
Wie kann ich für diese Zellen mit Suchen&Ersetzen eine doppelte Zellenhöhe zuweisen, damit der Text in die Zelle passt? Geht das per GREP oder nur mit einem Script (von dem ich immer noch keine Ahnung habe... 🫢)
vg
Copy link to clipboard
Copied
Moin,
wenn die Zellenhöhe auf "Mindestens" gestellt sind, sollten sie sich doch von alleine anpassen.
Copy link to clipboard
Copied
Moin Mario,
das ist richtig, allerdings kann ich dann die Zeilenhöhen nicht wirklich kontrollieren und die Tabelle »flattert« am unteren Rand aus. Das ist nicht gewünscht und läßt sich nur mir einer fixen Höhe verhindern.
Copy link to clipboard
Copied
Hi @jdh2023, when you say that you want a cell to have double row height, do you mean the whole row will have double row height? Or do you want to merge the cell with the cell below it to make just that cell double row height (and the below cell is gone)?
- Mark
Copy link to clipboard
Copied
Hello m1b,
the lines should be double height, not merged.
In addition, the heights of the cells vary from table to table, sometimes the rows are 4mm high, sometimes only 3.8mm and, accordingly, with two lines then 8mm or 7.6mm...
Copy link to clipboard
Copied
Hi @jdh_gd, I've written a quick script to do that. It reads the height of the first body row and uses that to dictate the heights of all the other body rows. For example:
/**
* Set table row heights to a factor of the row height
* of first body row of table.
* @author m1b
* @discussion https://community.adobe.com/t5/indesign-discussions/tabellen-nach-überlauftext-suchen-und-zellenhöhe-anpassen/m-p/14225092
*/
function main() {
var doc = app.activeDocument;
if (doc.selection.length == 0)
return alert('Please select one or more tables and run script again.');
var tables = getTables(doc.selection),
rowHeight;
tablesLoop:
for (var i = 0; i < tables.length; i++) {
rowsLoop:
for (var r = 0; r < tables[i].rows.length; r++) {
var row = tables[i].rows[r];
if (row.rowType == RowTypes.HEADER_ROW)
// ignore header rows
continue rowsLoop;
row.autoGrow = false;
if (rowHeight == undefined)
// get the row height of first body row of table
rowHeight = row.height;
row.height = rowHeight;
cellsLoop:
for (var c = 0; c < row.cells.length; c++)
// if the cell overflows, expand it by master row height
while (row.cells[c].overflows) {
row.height += rowHeight;
row.cells[c].recompose();
}
}
}
};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Set table row heights");
/**
* Returns array of Tables found in `items`.
* @author m1b
* @version 2022-02-01
* @param {Array<PageItem>} items - the items to look through.
* @param {Array<Table>} found - private parameter.
* @returns {Array<Table>}
*/
function getTables(items, found) {
if (items == undefined) return [];
if (found == undefined) found = [];
if (!items.hasOwnProperty('0')) items = [items];
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (
// item is a table
item.constructor.name == 'Table'
) {
found.push(item);
} else if (
// item contains tables
item.hasOwnProperty('tables')
&& item.tables.length > 0
) {
found = found.concat(getTables(item.tables));
} else if (
// parent is a table cell
item.hasOwnProperty('parent')
&& item.parent.constructor.name == 'Cell'
) {
found = found.concat(getTables([item.parent.parent]));
} else if (
// is in a story, which may contain tables
item.hasOwnProperty('parentStory')
) {
found = found.concat(getTables([item.parentStory]));
} else if (
// contains page items, which may be tables
item.hasOwnProperty('pageItems')
&& item.pageItems.length > 0
) {
found = found.concat(getTables(item.pageItems));
} else if (
// has a parent which might be a table
item.hasOwnProperty('parent')
&& item.parent.constructor.name != 'Document'
) {
found = found.concat(getTables([item.parent]));
}
}
return found;
};
Let me know if that is what you expected. - Mark
Copy link to clipboard
Copied
Wow, this is amazing! It works perfect, thank you very much!!
Copy link to clipboard
Copied
Great to hear!
Copy link to clipboard
Copied
if you set up your ParaStyle correctly - set LEADING to some specific value - height of the rows will multiply automatically:
Copy link to clipboard
Copied
Hello Robert,
thank you very much for the tip, but if the size of the font is changed, then it will be quite a bit of fiddling to get it to register correctly...
The option with a fixed row height is much easier and faster.
Copy link to clipboard
Copied
But then you need a dedicated script...
Finding a right leading is just a few seconds...