Skip to main content
The _to_bytes variants take the same arguments as their file counterparts, minus filename, and hand back bytes.
This matters wherever the filesystem is awkward: read-only containers, Lambda’s ephemeral storage, or any web server where writing a temp file means cleaning it up afterwards.

Serving from a web framework

That long media type is the correct one for .xlsx. Serving application/vnd.ms-excel instead, which is the older .xls type, makes some browsers mislabel the download.

Straight to object storage

Multiple sheets to bytes

Here num_threads defaults to 1, unlike the file-writing write_sheets_arrow where it’s required.

Memory

Jetxl holds the entire workbook in memory before returning it. For a million-row sheet that’s on the order of a gigabyte during generation, which is fine on a server and potentially fatal in a small Lambda. Write to a file for very large exports, or split the work.