The Import feature enables you to import records from an external Excel/CSV file to database table.
How to Use
To enable the feature for a table, select the table and click the Table tab, then enable the Import checkbox.
After generation, an Import button will be displayed in the table list page.
To start importing the external records, click the Import button and an Import dialog box will be displayed. Click the Choose button to select the file for import, and the import process will begin. Click the Close button once the import process is completed to refresh the list page.
Important Notes
Table Specific -> List Page | |
---|---|
Page_Importing |
This server event allows you to modify the Import options before the import process begins. Arguments are: $reader - File reader (\PhpOffice\PhpSpreadsheet\Reader\IReader) You can return FALSE to skip importing the file. The options (accessed by $options["<value>"]) you can change during this event are: Example 1 Import selected records only $options["offset"] = 10; // Skip the first 10th records Example 2 The spreadsheet contains pure data only. Supply the header manually. $options["headers"] = ["CategoryName", "Description"]; Example 3 Change input encoding, delimiter and enclosure for CSV file $options["inputEncoding"] = "CP1252"; // Use CP1252 for input encoding $options["delimiter"] = ";"; // Semi-colon for delimiter $options["enclosure"] = "'"; // Single quote for enclosure |
Row_Import |
This server event is executed before a record is imported. Arguments are: $row - Array of data to be imported You can return FALSE to skip importing the row. Example 1 Modify data before import $row["Trademark"] = ExecuteScalar("SELECT ID FROM trademarks WHERE Trademark ='" . AdjustSql($row["Trademark"]) . "'"); // Get Trademark ID from trademarks table Example 2 Validate input data if (intval($row["Quantity"]) > 100) // Quantity must be <= 100 return FALSE; // Skip import |
Page_Imported |
This server event is executed after import is completed. Arguments are: $reader - File reader (\PhpOffice\PhpSpreadsheet\Reader\IReader) The data available in the results array are (accessed by $results["<value>"]): Example Write audit trail for import $msg = "imported " . $results["totalCount"] . " records (successful: " . $results["successCount"] . " / failed: " . $results["failCount"] . ") from " . $results["file"]; // Set up import message WriteAuditTrail("log", DbCurrentDateTime(), ScriptName(), CurrentUserID(), $msg, CurrentUserIP(), "", "", "", ""); // Write audit trail |
Import maximum execution time (seconds) | Maximum executing time for import. Default value is 300 (5 minutes). Change to a larger value if you are importing a lot of records. |
Import records by insert only | Only insert is performed. Default value is true. Uncheck if you also want to update records with the same primary key.
Important
|
Import records by transaction | Use transaction for import. Default value is false. Change to true if you want an ALL OR NOTHING import. |
Import supported file extensions | Supported file extensions for import (comma separated) |
Import to CSV delimiter | Delimiter for CSV file for import. Default value is , (comma). |
Import to CSV quote character | Quote for CSV file for import. Default value is " (double quote). |