i'm trying to write to a BytesIO a partial xls file, in order to stream back to the client an excel file.
The problem is that the client gets only the first few rows (first yield iteration to the byteio object)
It looks like the save_to_memory is adding EOF bytes although the stream should not be closed
Example code:
import io
import pyexcel as pe
from aiohttp import web
async def get(request):
response = web.StreamResponse(headers={'Content-Disposition': 'inline; filename="myfile.xls"'})
await response.prepare(request)
response.content_type = 'multipart/x-mixed-replace;boundary=ffserver'
data = [1,2,3,4]
mem = io.BytesIO()
sheet = pe.Sheet(name='ids', colnames=['id'])
try:
for id in data:
sheet.extend_rows([id])
mem = sheet.save_to_memory("xls", mem)
await response.write(mem.read())
finally:
await response.write_eof()
in this case the only row the client would get is with value 1
This is what I did: -