Without any package, I think it will be difficult.
Have you tried this package which is writtent to work with Laravel ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Is there a way to export Excel Spreadsheet (not XML) using Laravel and not using an Excel package? Currently, I have the following code which does export , but from what I read, it's creating an XML file. So when I try to open the file, I get the following message:
"The file format and extension of test.xls don't match. The file could be corrupted or unsafe. Unless you trust it's sources don't open it..." After opening, the file format is set the Web Page (html) not xls.
Controller:
$querydata = "sql";
$content = view('file', compact('data'));
$status = 200;
$headers = [
'Content-Type' => 'application/vnd.ms-excel; charset=utf-8',
'Content-Disposition' => 'attachment; filename='test.xls',
];
$response = response($content, $status, $headers);
It will take some work. Read the source of something like this to see how it can be done https://github.com/spatie/simple-excel/blob/main/src/SimpleExcelWriter.php
Please or to participate in this conversation.