Django: Export data from database to an existing excel template file

I am currently making a function on web that outputing a invoice file (in xls), which contains some stored info from db (e.g. clients address, product name…).
And I have this invoice template already, so is there any method could make django outputs data from db and modify on my existing template in excel format?

You can’t emit an xls (or xlsx?) file from a template. You would need to create it as a file, and then return it to the browser as a FileResponse.