Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hellomorning01's avatar

Export an Excel file to report an error when importing data from an Excel file into the database.

I have a task when importing multiple data from an excel file into a database using Laravel Excel: if a row in there is different from the validation rules(); it will create an excel file reporting which row's column the error appears in.

For example, if I import an Excel's product file with 3 columns

  • Name (a-zA-Z0-9)
  • Category Name (a-zA-Z0-9, must exist in the category table)
  • Price (Numberic)

If product's name has a special character in it will output an Excel. And in each row, the location of the error data will be reported, for example:

If error at price, A-12 is special character or: Name, Category, Price ("Error at A-12 ", "Category Name", "Price")

If error at price, at C-20 is character and not numberic: ("Product Name ", "Category Name", "Error at C-20")

0 likes
1 reply
tangtang's avatar

@hellomorning01

you can use regex each field you want to validated and show the error text (but this is manual approach)

Please or to participate in this conversation.