DEV Community

Harisu-Ishbah
Harisu-Ishbah

Posted on

"Return value of Maatwebsite\\Excel\\Sheet::mapArraybleRow() must be of the type array, int returned"

Hello, why i get this error?
what's the solution ?

view (Ajax) :

`            $('#export').click(function (e) {
            let rows_selected = tblMassy.column(0).checkboxes.selected();
                        if (rows_selected.length >= 1)  {

                            $.each(rows_selected, function(index, rowId){

                                console.log( "http://localhost:8000/eksportfilter/" + rowId ) ;
                                // location.href= "/eksportfilter/" + rowId;
                                $.ajax({
                                    type:'POST',
                                    url: "http://localhost:8000/eksportfilter/" + rowId,
                                    dataType: "JSON",
                                    success: function (response) {
                                        console.log( response )
                                    }
                                });   
                            });
                                console.log(rows_selected.length);

                                swal("Good job!", "Eksport data successfully!", "success");

                                $('#tblMassy').DataTable().ajax.reload();
                                // location.reload();
                        } else {
                            swal("Failed Export!", "No Data Delected!", "error");
                        }
        });`
Enter fullscreen mode Exit fullscreen mode

my controller :

` public function eksportfilter($id)
    {
            $data = [
                'id' => $id,

                $m_assy = m_assy::find($id)
            ];
            return Excel::download(new TransactionsExportFilter($m_assy), 'users.xlsx');
    }`
Enter fullscreen mode Exit fullscreen mode

Maatwebsite Export :

`public function __construct($data)
    {
        $this->data = $data;
    }


    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        return collect($this->data);
    }

    public function headings(): array
    {
        return [
            'id',
            'assymainharness',
            'assyab',
            'assyab1',
            'assyab2',
            'assyab3',
            'type',
            'assycode',
            'suffixlevel',
            'desccarline',
            'factory',
            'customer',
        ];`
Enter fullscreen mode Exit fullscreen mode

Can anyone help me solve this problem ?

Top comments (0)