Can Macros be used to add and removes lines from tables

Let us say I have a table sort of like this:

image

I would like to have a brace of buttons that would allow me to add rows to this table. (It would save certain users some time.)

Can a Macro be used to do this? I would also need some way of removing rows from the table, either the bottom row or a little X by each one.

Bonus Questions:
Can we populate some of the cells with a dropdown list?
Is this doable with a Python Macro?

Thanks for any assistance.

Are you sure Writer is the best tool for that. Table cells in Writer are meant to contain text. From some point of view, a table cell is a full sub-document. Your description rather suggests you’ll have a time-growing table with little data in each cell and a row being some basic unit of information.

Could it be simpler in Calc?

I can probably do that; the people actually using the document sent me the template as a writer document, that’s all.

If someone can point me to some reference documents that has things like “shifting cells down” and such, I would probably accept that as a solution as well…

We could print it as a PDF or something ;apparently, this needs to be viewed on people’s cell phones.

With a database form, you could do all that with list boxes, sort orders, filters, without a single line of code and print any resulting subset of data to PDF.

Add row in the first table.

doc = XSCRIPTCONTEXT.getDocument()

table = doc.TextTables[0]
table.Rows.insertByIndex(table.Rows.Count, 1)

Remove by index

table.Rows.removeByIndex(1, 1)