Page_Importing
This server event allows you to modify the Import options before the import process begins. The first argument is a workflow builder function and the second argument is an array containing the import options. You can also return false to skip the import.

The keys of the options are:
headerRowNumber - Header row number (default is 0, zero-based)
headers - Header array (default is empty array)
inputEncoding - Input encoding for data (CSV only, default is "UTF-8")
delimiter - Delimiter for data (CSV only, default is ',')
enclosure - Quote character for data (CSV only, default is '"')
escape - Escape character for data (CSV only, default is '\\')
activeSheet - Index of active sheet to read from (For PhpSpreadsheet only, default is null)
readOnly - If set to false, the reader take care of the spreadsheet formatting (slow) (For PhpSpreadsheet only, default is true)
maxRows - Maximum number of rows to read (For PhpSpreadsheet only, default is null) offset - Skip a certain amount of items from the beginning (For OffsetFilter, default is 0)
limit - Process only specified amount of items (and skip the rest) (For OffsetFilter, default is null)

Example 1

The spreadsheet contains pure data only. Supply the header manually.

Example 2

Change input encoding, delimiter and enclosure for CSV file

Example 3

Use the workflow builder function to customize the workflow object for import, e.g. add a FilterStep to the workflow. The filter step determines whether the input data should be processed further. If any of the callables in the step returns false, the data will be skipped from processing.

For other built-in steps, see StepAggregator. You can also write your own steps.

Row_Import
This server event is executed before a record is imported. The first argument is an array containing the data to be imported and the second argument is an integer containing the current import record count. You can return false to skip the import.

Example 1

Modify data before import

Example 2

Convert Excel dates (stored as sequential serial numbers) to strings. Note that ``NumberFormat`` in this example is ``\PhpOffice\PhpSpreadsheet\Style\NumberFormat``.

Example 3

Validate input data

Page_Imported
This server event is executed after import is completed. Note that this event is fired for each imported file.

The first argument ($object) is the workflow result object, it contains counts and information about exceptions.

The second argument ($results) is an array containing additional information of the import results, the keys of the array are:
file - File name of the imported file
totalCount - Total records imported
successCount - Total records imported successfully
failCount - Total records imported unsuccessfully
success - Whether or not all records imported successfully, or the failure count does not exceed the Import maximum number of failures (see advanced settings)
rollbacked - Whether or not any rollback is perfomed. If Import records with transaction (see advanced settings) is enabled, the transaction will be rollbacked after trial import.

Example

Write audit trail for import