1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Laravel-excel export not downloading instead its just storing

Discussão em 'Outras Linguagens' iniciado por Edson, Novembro 3, 2024 às 06:32.

  1. Edson

    Edson Guest

    I have this laravel project where i added this package laravel-excel to export data from database now instead of downloading it is saving to this directory storage\framework\cache\laravel-excel

    this is my vue code

    <script setup>

    import { router} from '@inertiajs/vue3';
    import { ref } from 'vue'
    const props = defineProps({transactions:Object});

    const status =ref('Status');
    const shop =ref('Shop');

    const handleExport = ()=>{
    const formData = new FormData();
    formData.append('status', status.value);
    formData.append('shop', shop.value);

    router.post('/export_data', formData,{
    preserveState: true, preserveScroll: true,
    })
    }
    </script>

    <template>
    <button @click="handleExport()" type="button"></button>
    </template>


    here is my controller code

    <?php

    namespace App\Http\Controllers;

    use App\Exports\TransactionsExport;
    use App\Models\Transaction;
    use Illuminate\Http\Request;
    use Maatwebsite\Excel\Facades\Excel;

    class TransactionController extends Controller
    {
    public function export_data(Request $request)
    {
    $status = $request['status'];
    $shop = $request['shop'];

    $result = Transaction::where([['status',$status],['shop',$shop]])->get();
    return Excel::download(new TransactionsExport($result), 'Transactions.xlsx');
    }
    }


    additional information, am getting the right data but again instead of downloading its just saving.

    thanks

    Continue reading...

Compartilhe esta Página