Page 1 of 1

Import excel file with Page_Importing event

Posted: Fri Oct 07, 2022 12:14 am
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;
 }

Re: Import excel file with Page_Importing event

Posted: Sat Oct 08, 2022 9:22 am
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.


Re: Import excel file with Page_Importing event

Posted: Sat Oct 08, 2022 10:01 am
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;
 }

Re: Import excel file with Page_Importing event

Posted: Tue Oct 11, 2022 6:44 pm
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


Re: Import excel file with Page_Importing event

Posted: Tue Oct 11, 2022 6:54 pm
by mobhar

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


Re: Import excel file with Page_Importing event

Posted: Tue Oct 11, 2022 7:21 pm
by saleh

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


Re: Import excel file with Page_Importing event

Posted: Tue Oct 11, 2022 9:42 pm
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.


Re: Import excel file with Page_Importing event

Posted: Wed Oct 12, 2022 12:28 am
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


Re: Import excel file with Page_Importing event

Posted: Wed Oct 12, 2022 10:49 am
by Webmaster

Update template and try again.


Re: Import excel file with Page_Importing event

Posted: Wed Oct 12, 2022 11:07 am
by saleh

Webmaster wrote:

Update template and try again.

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

It works successfully
Both problems are over
thank you