From the docs on writing to disk:
https://anvil.works/docs/working-with-files/media/files_on_disk#read-and-write-files-as-normal
Files in your filesystem are temporary, and may be removed without warning. We advise you only to access files in the /tmp directory.
The above code works for me on the full python runtime but not in the python 3.10 runtime.
So I’d suggest changing the code
final = WB.save("/tmp/doc.xlsx")
app_tables.table_1.add_row(doc=anvil.media.from_file("/tmp/doc.xlsx"))
I also like this version:
with anvil.media.TempFile() as f:
final = WB.save(f)
app_tables.table_1.add_row(doc=anvil.media.from_file(f, name="doc.xlsx"))
If you don’t provide a media object to TempFile
you just get a temp file location you can use within a with
block