Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Import ToArray returns null #4265

Open
1 task done
melihtanriyakul opened this issue Jan 23, 2025 · 0 comments
Open
1 task done

[Bug]: Import ToArray returns null #4265

melihtanriyakul opened this issue Jan 23, 2025 · 0 comments
Labels

Comments

@melihtanriyakul
Copy link

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

  • Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.62

What version of Laravel are you using?

9.52.19

What version of PHP are you using?

8.3.8

Describe your issue

I have been using the (new ObjectImport)->toArray($path) function in order to import multiple sheets but with some files it just returns null.

I have included two files in the attachment, one(0001104659-16-155721.xlsx) returns null in an array of array, the other returns the correct result of array[96].

How can the issue be reproduced?

You can find the excel files in the attachment.

0001104659-16-155721.xlsx
0001104659-17-065845.xlsx

  1. Create an Import class
<?php

namespace App\Imports;

use Maatwebsite\Excel\Concerns\Importable;
use Maatwebsite\Excel\Concerns\ToArray;

class FilingsImport implements ToArray
{
    use Importable;

    public function array(array $array)
    {
        // TODO: Implement array() method.
    }
}
  1. Use this import class in another class(in my case it's in a job):

$allSheets = (new FilingsImport)->toArray($this->path);

This is the return I got with a valid excel file(0001104659-16-155721.xlsx):

array (
  0 => 
  array (
    0 => 
    array (
      0 => NULL,
    ),
  ),
)

Yet another valid excel file(0001104659-17-065845.xlsx) returns the correct result of array[96].

What should be the expected behaviour?

Expected behavior should be that it returns the correct result of array of 108 since there is 108 sheets in the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant