Import excel file with Page_Importing event

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
saleh
User
Posts: 470

Import excel file with Page_Importing event

Post by saleh »

Already when I use the code for phpmaker 2022 it works successfully:

 // Page Importing event phpmaker2022
 function Page_Importing($reader, &$options) {
 	//var_dump($reader); // Import data reader
 	//var_dump($options); // Show all options for importing
 	//return FALSE; // Return FALSE to skip import
 
 	$options["headers"] = ["Management","SectID","GENDER","School_name","SchoolID","stage","almada","alsaf",
     "alfaqrat1","alfaqrat2","alfaqrat3","alfaqrat4","alfaqrat5","alfaqrat6",
     "alfaqrat7","alfaqrat8","alfaqrat9","alfaqrat10","alfaqrat11","alfaqrat12",
     "alfaqrat13","alfaqrat14","alfaqrat15",
 
 "alfaqrat16","alfaqrat17","alfaqrat18","alfaqrat19","alfaqrat20","alfaqrat21",
     "alfaqrat22","alfaqrat23","alfaqrat24","alfaqrat25","alfaqrat26","alfaqrat27",
     "alfaqrat28","alfaqrat29","alfaqrat30",
     "percentage","percentage1","number_students","week_id"
     ];
 	$options["offset"] = 12; // Skip the first 10th records
 
 
 	return TRUE;
 }

When using the phpmaker2023 code the import fails

I noticed there is a difference between codeine
phpmaker2023 :($builder, &$options)
phpmaker2022 :($reader, &$options)

 // Page Importing event phpmaker2023
 function Page_Importing($builder, &$options) {
 	//var_dump($builder); // Import data builder
 	//var_dump($options); // Show all options for importing
 	//return FALSE; // Return FALSE to skip import
 
 	$options["headers"] = ["Management","SectID","GENDER","School_name","SchoolID","stage","almada","alsaf",
     "alfaqrat1","alfaqrat2","alfaqrat3","alfaqrat4","alfaqrat5","alfaqrat6",
     "alfaqrat7","alfaqrat8","alfaqrat9","alfaqrat10","alfaqrat11","alfaqrat12",
     "alfaqrat13","alfaqrat14","alfaqrat15",
 
 "alfaqrat16","alfaqrat17","alfaqrat18","alfaqrat19","alfaqrat20","alfaqrat21",
     "alfaqrat22","alfaqrat23","alfaqrat24","alfaqrat25","alfaqrat26","alfaqrat27",
     "alfaqrat28","alfaqrat29","alfaqrat30",
     "percentage","percentage1","number_students","week_id"
     ];
 	$options["offset"] = 12; // Skip the first 10th records
 
 
 	return TRUE;
 }

arbei
User
Posts: 9359

Post by arbei »

You did not use the $reader argument, so the change does not affect your code, you may test if your old code still works with the latest template. If it does not work, you may follow viewtopic.php?t=54215 and learn how to debug.


saleh
User
Posts: 470

Post by saleh »

The code is working successfully in phpmaker2023

 // Page Importing event phpmaker2022
 function Page_Importing($reader, &$options) {
 	//var_dump($reader); // Import data reader
 	//var_dump($options); // Show all options for importing
 	//return FALSE; // Return FALSE to skip import
 
 	$options["headers"] = ["Management","SectID","GENDER","School_name","SchoolID","stage","almada","alsaf",
     "alfaqrat1","alfaqrat2","alfaqrat3","alfaqrat4","alfaqrat5","alfaqrat6",
     "alfaqrat7","alfaqrat8","alfaqrat9","alfaqrat10","alfaqrat11","alfaqrat12",
     "alfaqrat13","alfaqrat14","alfaqrat15",
 
 "alfaqrat16","alfaqrat17","alfaqrat18","alfaqrat19","alfaqrat20","alfaqrat21",
     "alfaqrat22","alfaqrat23","alfaqrat24","alfaqrat25","alfaqrat26","alfaqrat27",
     "alfaqrat28","alfaqrat29","alfaqrat30",
     "percentage","percentage1","number_students","week_id"
     ];
 	$options["offset"] = 12; // Skip the first 10th records
 
 
 	return TRUE;
 }

saleh
User
Posts: 470

Post by saleh »

The import using version v2023.3.0 is now successful :

// Page Importing event
function Page_Importing(&$builder, &$options) {
	//var_dump($builder); // Import data reader
	//var_dump($options); // Show all options for importing
	//return FALSE; // Return FALSE to skip import

	$options["headers"] = ["Management","SectID","GENDER","School_name","SchoolID","stage","almada","alsaf",
    "alfaqrat1","alfaqrat2","alfaqrat3","alfaqrat4","alfaqrat5","alfaqrat6",
    "alfaqrat7","alfaqrat8","alfaqrat9","alfaqrat10","alfaqrat11","alfaqrat12",
    "alfaqrat13","alfaqrat14","alfaqrat15",

"alfaqrat16","alfaqrat17","alfaqrat18","alfaqrat19","alfaqrat20","alfaqrat21",
    "alfaqrat22","alfaqrat23","alfaqrat24","alfaqrat25","alfaqrat26","alfaqrat27",
    "alfaqrat28","alfaqrat29","alfaqrat30",
    "percentage","percentage1","number_students","week_id"
    ];
	$options["offset"] = 12; // Skip the first 10th records


	return TRUE;
}

But there is a note
I have very large records, so I do not want them to appear in the import, as in the image below


mobhar
User
Posts: 11703

Post by mobhar »

You may disable Import records with transaction option under Tools -> Advanced Settings, after that re-generate ALL the script files again.


saleh
User
Posts: 470

Post by saleh »

The selection has been removed as in the image below
Unfortunately, it still displays the log lines.


arbei
User
Posts: 9359

Post by arbei »

saleh wrote:

Unfortunately, it still displays the log lines.

That is not "log lines", it is the import result, but it seems that it is not displayed properly in your RTL site.


saleh
User
Posts: 470

Post by saleh »

There are only two problems:

1- The problem of formatting from the Arabic language file, while in English the format appears successfully

2- Processed 85 of 96 records from aa.xlsx (success: 85, failure: 0)
$options["offset"] = 11; // Skip the first 10th records
I have, for example, start importing records from record No. 11
But counting records starts from record 1
Processed 85 of 96 records : 85+11=96
I hope you understand what I'm saying


Webmaster
User
Posts: 9427

Post by Webmaster »

Update template and try again.


saleh
User
Posts: 470

Post by saleh »

Webmaster wrote:

Update template and try again.

تمت معالجة 85 من 85 سجلات من aa.xlsx (نجاح: 85, فشل: 0)

It works successfully
Both problems are over
thank you


Post Reply