Begin excel file download.
Produces this error:
ErrorException in CssParser.php line 63:
file_get_contents(/build/css/app-b780ec6a83.css): failed to open stream: No such file or directory
I just started using this package today and am still in the process of trying to get my first view export to work, but I haven't been able to find this issue anywhere else. The CSS parser seems to be having trouble finding my versioned CSS file. Even changing it to point directly to my /css/app.css file still produces this issue as well. The rest of my site doesn't have any errors and renders properly.
Update - Making this change seems to fix it, but doesn't let me use elixir for versioning my CSS:
<link rel="stylesheet" type="text/css" href="{{ elixir('css/app.css') }}">
to
<link rel="stylesheet" type="text/css" href="css/app.css">
Any idea what change I can make to continue using Elixir?
Update 2 - I found that removing the '/'. from this function (the first one after return) in \vendor\laravel\framework\src\Illuminate\Foundation\helpers.php allows the download, but can cause issues elsewhere:
if (isset($manifest[$file])) {
return '/'.trim($buildDirectory.'/'.$manifest[$file], '/');
}
Has anyone else run into this?
Thanks in advance!
In shouldn't be really necessary to use a versioned file in the excel export, as versioning is meant for browser cache busting. Excel export doesn't cache the css file.
I would also suggest using a custom css file for your excel file, as loading the entire app.css will have serious overhead.
Awesome, thanks for your help Patrick. Maybe you can tell me if I'm going about this process correctly. Currently, I'm trying to export a view that contains a report (a simple table). This view is the actual page people would be using to view the report on the site. With your recommendation, do you mean I should change that view to not use my layout template? Or do you mean I should be building a separate view to use for the actual Excel export?
Thanks again!
Best to make your table a partial and @include it in your view.
You then can load that partial inside an excel view as well.
Both views can have their own css file.
I ended up using the solution from your final comment and everything works great. It makes so much more sense to do it that way. I'm going to try to apply that way of thinking to the rest of my project as well.
hi, i got this issue as well.
controller:
Excel::create('clients', function($excel) {
$excel->sheet('Sheetname', function($sheet) {
$sheet->loadView('posyandu/laporanWarta');
});
})->export('xlsx');
blade:
<table class="table">
<thead>
<tr>
<th></th>
<th>BARU</th>
<th>LAMA</th>
<th>TOTAL</th>
</tr>
<tr>
<th>BAYI</th>
<th>1</th>
<th>2</th>
<th>3</th>
</tr>
<tr>
<th>ANAK</th>
<th>4</th>
<th>5</th>
<th>6</th>
</tr>
<tr>
<th>TOTAL</th>
<th>7</th>
<th>8</th>
<th>9</th>
</tr>
</thead>
</table>
Most helpful comment
Best to make your table a partial and @include it in your view.
You then can load that partial inside an excel view as well.
Both views can have their own css file.