I don't believe you are going to find a way to do this using just Laravel Excel — most people would create a new sheet for each dataset. But ultimately, you can format the data however you like if you build your output array manually.
Here's one way you could do it.
Controller
Pass in the arrays directly to the export class, instead of a collection.
$arrays = [$level_one_array, $level_two_array, $level_three_array];
return Excel::download(new YourExportClass($arrays), 'YourFilename.xlsx');
Export
Build an output array corresponding to your desired layout, then wrap it in a collection.
class YourExportClass implements FromCollection
{
use Exportable;
private $collection;
public function __construct($arrays)
{
$output = [];
foreach ($arrays as $array) {
// get headers for current dataset
$output[] = array_keys($array[0]);
// store values for each row
foreach ($array as $row) {
$output[] = array_values($row);
}
// add an empty row before the next dataset
$output[] = [''];
}
$this->collection = collect($output);
}
public function collection()
{
return $this->collection;
}
}
collection()method of the export class, can you return a collection of collections? docs.laravel-excel.com/3.1/exports/collection.html