I would use a data manipulation language like R or Python with Quarto to generate the LaTeX programmatically. Then the document generation gets separated from the template design. Quarto is a system for generating LaTeX and HTML and docx files. R currently has more data rendering packages than Python, but either can probably do it.
(I somehow replied with the above to the wrong thread a few days ago. Hope this works.)