I can click and drag each horizontal line one by one manually to match amount of content of the cell above it (how many lines of text it has), but what if you have 100 rows?
This can be achieved using a bound-to-your-Doc Google Apps Script. You can write a function to make all rows' height the minimum possible for tables in the Document, and for those rows with content height larger than minimum, the minimum for that row will be applied (Not hiding any of the content).
function fixCellSize() {
DocumentApp.getUi().alert("All row heights will be minimized to content height.");
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var tables = body.getTables();
for each (var table in tables) {
for (var i=0; i < table.getNumRows(); i++){
Logger.log("Fantasctic!");
table.getRow(i).setMinimumHeight(1);
}
}
}
If you would like to make the function available in the menu, then you could create a Custom Menu with a function like the following:
function onOpen() {
var ui = DocumentApp.getUi();
ui.createMenu("Custom Menu").addItem("Fix cell sizes", "fixCellSize").addToUi();
};
By putting this functions in a bound script you will get what you are looking for.
You can try it out in this Document showcasing it.