Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

Fast-Excel - is it possible to make the browser "know" the downloaded file size(or time remaining) when downloading by chunks?

Hi,

I'm using rap2hpoutre/fast-excel, and when I use the generator method (chunks) to download large files, the browser doesn't show the final file size and estimated time left. (source: https://github.com/rap2hpoutre/fast-excel?tab=readme-ov-file#export-large-collections-with-chunk)

I assume it's by design because the browser can't tell the size as it's being downloaded by chunks? But is there a way to perhaps make the browser know this information?

I just want the users to see the information in the browser.

Because instead of this:

my-large-excel.xlsx
5.5/200 MB ● 2 minutes left

It shows something like this:

my-large-excel.xlsx
5.5 MB downloaded

This is how I'm using it:

// in some controller
public function download()
{
    $data = SomeQuery();
    return (new FastExcel($this->fast_excel_generator($data)))->download('filename.xlsx');
}

public function fast_excel_generator($data)
{
    foreach ($data->cursor() as $row) {
        yield $row;
    }
}

Thanks

0 likes
4 replies
Snapey's avatar

You miss-understand. The file is assembled in chunks to avoid large memory load. When it is ready, it is streamed to the client.

It is NOT downloaded in chunks.

Most browsers will show a download progress indicator without you doing anything.

1 like
Ligonsker's avatar

@Snapey Oh, so do you have an idea why it doesn't show the indicator when I use the generator (chunks) method of Fast-Excel? I'm only using Fast-Excel with the chunks method, so I am not sure if it's only this method that's doing that or all of the Fast-Excel methods, but other packages of excel downloads do not do that because I'm using another package as well for the less-heavy Excel files

Edit: This is how I'm using it (Also added this to the question):

public function download()
{
    $data = SomeQuery();
    return (new FastExcel($this->fast_excel_generator($data)))->download('filename.xlsx');
}

public function fast_excel_generator($data)
{
    foreach ($data->cursor() as $row) {
        yield $row;
    }
}
Snapey's avatar

@Ligonsker

You miss-understand. The file is assembled in chunks to avoid large memory load. When it is ready, it is streamed to the client.

It is NOT downloaded in chunks.

Most browsers will show a download progress indicator without you doing anything.

THERE IS NO SUCH THING AS CHUNKED DOWNLOAD

1 like
Ligonsker's avatar

@Snapey yes I meant the method of assembling it in chunks, not "downloading in chunks", i.e.:

public function fast_excel_generator($data)
{
    foreach ($data->cursor() as $row) {
        yield $row;
    }
}

So I meant this. And the fact that it happens only with Fast-Excel and not other packages like maatwebsite/excel (On the same page even)

Please or to participate in this conversation.