Hi,
You can try altering the filepath to a location where your program has the appropriate rights to write files to resolve this error. You could also use the 'tempfile' module to create a temporary file in a location where the program can write, and then send that file as the download instead.
For example, you may change the 'filepath' line to read:
import tempfile
...
filename = "toplivo.xlsx"
with tempfile.TemporaryDirectory() as tmpdir:
filepath = os.path.join(tmpdir, filename)
...
# Save workbook and return file for download
This will create a temporary directory where your program is allowed to write files, and create the "toplivo.xlsx" file inside that directory.
I hope this helps!