How can I delete empty lines in OpenOffice Calc?
So you will have all empty rows at the end and you will have to remove only if there is some formatting.
That technique would not be much efficient if you have sparse data (a lot of empty cells between data) in "table" without a "custom header" (if you have not put the first line with the name of columns).
PS: Sometimes when I sort data on table, it sorts also the header, so it is moved from the top of worksheet to another position. To avoid that, freeze header row/rows before sorting.
Right-click the column or row header, and a pop-up menu will appear. Then click Delete Row or Delete Column.
Optionally, you can select multiple rows or columns first, in which case you can delete them all at once.