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
[QUESTION] Attach generated excel with V 3.1 #1910
Comments
I have the exact same question. |
I've found a solution changing from protected to public the export() method inside the file: maatwebsite\excel\src\Excel.php on row: 166 in this way, the code can be:
|
I've found a solution to make it work without having to modify the Excel class and its protected method. You can call public function build()
{
return $this->markdown('emails.report')
->attach(
Excel::download(
new AuditReport($this->audit),
'report.xlsx'
)->getFile(), ['as' => 'report.xlsx']
);
}
Hope it helps 😃 |
Watch out for the server's tmp dir though as the file gets written to disk. Export should be a public method. |
Thanks guys for helping each other out! 👍 |
Here is how I do it without downloading/creating the file: use Maatwebsite\Excel\Excel as BaseExcel;
use Maatwebsite\Excel\Facades\Excel;
...
$filename = "{$this->po->po_memo}.xlsx";
$attachment = Excel::raw(new PurchaseOrderLinesExport($this->po), BaseExcel::XLSX);
$subject = "Purchase Order Invoice"
return $this->from($this->po->employee->email)
->subject($subject)
->view('emails.pom.send')
->text('emails.pom.send')
->attachData($attachment, $filename); |
Thanks for this, it worked for me. |
Thanks a lot. it's work for me |
Versions
Description
Hello,
how is it possible attach an excel file generated with the version 3.1?
In the previous version (v.2) it was possible through create method without "->download()"
I'm trying in this way, but it doesn't work:
The text was updated successfully, but these errors were encountered: