Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: /usr/share/nginx/html/storage/framework/cache/laravel-excel/laravel-excel-1psS0VMO9G0yPaBxMh62mwjJyCePqZAD.html is an Invalid HTML file. #4059

Closed
1 task done
al3xanderSL opened this issue Dec 26, 2023 · 2 comments
Labels

Comments

@al3xanderSL
Copy link

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

  • Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.51

What version of Laravel are you using?

10

What version of PHP are you using?

8.3

Describe your issue

I am having this error sometimes when I want to download an excel : /usr/share/nginx/html/storage/framework/cache/laravel-excel/laravel-excel-1psS0VMO9G0yPaBxMh62mwjJyCePqZAD.html is an Invalid HTML file.
I dont know why but sometimes it downloads me an excel with kb or not it depends i don´t know why too and other times it returns the error I have mentioned before.

How can the issue be reproduced?

my code is quite extensive so im going to show you just some parts of it.

the way I download it in my controller is like this :

 $response =  Excel::download(new GenerateXls($request['itemId'],$request['view'],$request['onlycovlocations'],$name),
                     'Disponible '.$request['itemId'].' '.Carbon::now()->format('Y:m:d').' '.Carbon::now()->format('h:i:s').'.xlsx');

Then part of the GeneratXls class is:


namespace App\Services\ItemOnHand;

use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use Maatwebsite\Excel\Concerns\WithStyles;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class GenerateXls implements FromView,ShouldAutoSize,WithStyles,ShouldQueue
{
    public $nView;
    public $covLocation;
    public $itemId;
    public $name;
    public $groupName;
    public $status;
    public $item;
    public $date;

    public function __construct($id,$view,$covLocation,$name){
        $this->name = $name;
        $this->itemId = $id;
        $this->covLocation = $covLocation;
        $this->nView = $view;
        $this->item = $this->getItemData();
        $this->groupName =  $this->getGroupName();
        $this->status = $this->getStatus();
        $this->date = $this->getDate();
    }


    public function view(): View
    {
        return view('reports.item-on-hand.item-on-hand-report', ['type'=>'xls','id'=>$this->itemId,'nView'=> $this->nView,'covLocation'=> $this->covLocation,'name'=>$this->name]);
    }
}

Eventually, the only blade I have is this : 
  <p>{{ $name }}</p>

### What should be the expected behaviour?

At least the suspected outcome is to download the excel and dont retrieve that error.
@khbtechservices
Copy link

I ran into this issue when using a view formatted for a generic CSV. I had to update my view to be formatted as an HTML table as shown in the docs.

@patrickbrouwers
Copy link
Member

Sounds like you Blade file generates invalid HTML, which PhpSpreadsheet cannot read. Please check your Blade file to make sure it's correct HTML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants