Failed to load D:xampphtdocswisatastorageframeworkcachelaravel-excellaravel-excel-TnuNdoEqijuZ2ap1N6clNw6ZAhOykcsr.html as a DOM Document

Issue

This Content is from Stack Overflow. Question asked by gtprow

I use export excel from website : https://docs.laravel-excel.com/3.1/exports/from-view.html to make the final report.

enter image description here

I’m using from view to export the query (‘kecamatan’) that exists in each table. But when I press the export button, an error like the one above appears and showing the error in this section:

  if ($loaded === false) {

        throw new Exception('Failed to load ' . $filename . ' as a DOM Document', 0, $e ?? null);

    }

I have tried everything for resolving this issue but nothing worked.

php artisan cache:clear | php artisan view:clear | php artisan route:clear | php artisan config:clear

what should i do to solve this excel export problem.

MyController :

public function exportlaporanakhir()
{
    return Excel::download(new ExportLaporanAkhir, 'data-laporan-akhir-sektor.xlsx');
}

MyExport

public function view(): View
{

    return view('Dashboard.Laporan.Akhir.LaporanFinalindex', [
        'laporanfinal' => Wisata::select('kecamatan', Wisata::raw('count(wisata.id) as jumlah_wisata'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal2' => Transportasi::select('kecamatan', Transportasi::raw('count(transportasi.id) as jumlah_transportasi'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal3' => Penginapan::select('kecamatan', Penginapan::raw('count(penginapan.id) as jumlah_penginapan'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal4' => Mall::select('kecamatan', Mall::raw('count(mall.id) as jumlah_mall'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal5' => Restaurant::select('kecamatan', Restaurant::raw('count(restaurant.id) as jumlah_restaurant'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal6' =>  Bioskop::select('kecamatan', Bioskop::raw('count(bioskop.id) as jumlah_bioskop'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal7' => Spa::select('kecamatan', Spa::raw('count(spa.id) as jumlah_spa'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal8' => Ukm::select('kecamatan', Ukm::raw('count(ukm.id) as jumlah_ukm'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal9' => Media::select('kecamatan', Media::raw('count(media.id) as jumlah_media'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),

        'laporanfinal10' => Komunitas::select('kecamatan', Komunitas::raw('count(komunitas.id) as jumlah_komunitas'))
            ->groupBy('kecamatan')
            ->OrderBy('kecamatan')
            ->get(),
    ]);

}

MyView

    <!-- Main content -->
<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <h2 class="card-title">DASHBOARD LAPORAN AKHIR WISATA</h2>
                    </div>

                    <!-- /.card-header -->
                    <div class="card-body table-responsive p-0">
                        <div class="card-tools mb-3 ml-3 mt-3"><a href="{{ route('exportlaporanakhir') }}"
                                class="btn btn-success"><i class="fas fa-print">
                                    CETAK LAPORAN </i></a></div>
                        <!-- <a href="#" class="btn btn-success"><i class="fas fa-plus-square"> Tambah Data </i></a> -->
                        <table class="table table-head-fixed text-nowrap">
                            <thead>
                                <tr>
                                    <th rowspan="2" style="text-align: center; padding: 0px 0px 35px 0px">NO</th>
                                    <th rowspan="2" style="text-align: center; padding: 0px 0px 35px 0px">
                                        SEKTOR</th>
                                    <th colspan="4" style="text-align: center">KECAMATAN</th>
                                </tr>
                                <tr>
                                    <th>Bumiaji</th>
                                    <th>Batu</th>
                                    <th>Junrejo</th>
                                </tr>
                            </thead>
                            <tbody>
                                @php
                                    $no = 1;
                                @endphp
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Destinasi</td>
                                    @foreach ($laporanfinal as $lapor)
                                        <td>{{ $lapor->jumlah_wisata }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Transportasi</td>
                                    @foreach ($laporanfinal2 as $index => $lapor2)
                                        <td>{{ $lapor2->jumlah_transportasi }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Penginapan</td>
                                    @foreach ($laporanfinal3 as $index => $lapor3)
                                        <td>{{ $lapor3->jumlah_penginapan }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Mall / Pasar</td>
                                    @foreach ($laporanfinal4 as $index => $lapor4)
                                        <td>{{ $lapor4->jumlah_mall }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Restaurant & Cafe</td>
                                    @foreach ($laporanfinal5 as $index => $lapor5)
                                        <td>{{ $lapor5->jumlah_restaurant }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Bioskop</td>
                                    @foreach ($laporanfinal6 as $index => $lapor6)
                                        <td>{{ $lapor6->jumlah_bioskop }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>SPA</td>
                                    @foreach ($laporanfinal7 as $index => $lapor7)
                                        <td>{{ $lapor7->jumlah_spa }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>UKM</td>
                                    @foreach ($laporanfinal8 as $index => $lapor8)
                                        <td>{{ $lapor8->jumlah_ukm }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Media</td>
                                    @foreach ($laporanfinal9 as $index => $lapor9)
                                        <td>{{ $lapor9->jumlah_media }}</td>
                                    @endforeach
                                </tr>
                                <tr>
                                    <td scope="item">{{ $no++ }}</td>
                                    <td>Komunitas</td>
                                    @foreach ($laporanfinal10 as $index => $lapor10)
                                        <td>{{ $lapor10->jumlah_komunitas }}</td>
                                    @endforeach
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer clearfix">
                        <ul class="pagination pagination-sm m-0 float-right">
                            {{-- {{ $laporanpenginapan1->links() }} --}}
                        </ul>
                    </div>
                </div>
                <!-- /.card -->
                <!-- /.card -->
            </div>
            <!-- /.col -->
            <!-- /.col -->
        </div>
        <!-- /.row -->
        <!-- /.row -->
    </div><!-- /.container-fluid -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?