1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravel-Excelで複数行のヘッダーを無視したい

Last updated at Posted at 2019-11-29

Laravel-Excelで複数行のヘッダーを無視したい時

Laravel Excel

ドキュメントをみたけれど、書いてなかったので(書いてありました。)、Issueに書いてあったことを記録しておきます。

例えば、ヘッダー行(1行目)を飛ばすのはオプションでありそうですが、複数行目(例:6行目からデータ行が始まっているので、)飛ばしたい場合、いかのように書いてやればいいです。

WithStartRowを使用します。

use Maatwebsite\Excel\Concerns\WithStartRow;

class UsersImport implements ToModel, WithStartRow
{
    /**
     * @return int
     */
    public function startRow(): int
    {
        return 6;
    }
}
1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?