Hi all:
Using v2019
I have a table with some fields:
id(AI),item,qty,serial
I have an excel file with this headers
id(null),item,description,qty,serial
I want to import the rows, check if item exist in a master table, and if it no exists, then add item to the master table with the description.
I’ve been following several posts, and I know I have to use Page_Importing and Row_Import to fit the headers to my table fields, and unset the excel fields I don’t want to import.
I’ve tried some solutions described in this two posts:
https://discourse.hkvstore.com/t/change-header-for-the-import-file/1789/4
https://www.hkvforums.com/viewtopic.php?f=4&t=45584&p=144329&hilit=import+excel+field#p144329
If I don’t make anything in the Page_Importing event, I get messages of unknown fields.
So in the Page_Importing I make:
function Page_Importing($reader, &$options) {
$options[“headers”] = [“id”,“item”,“qty”,“serial”];
$options[“offset”] = 1;
return TRUE;
}
and try to unset the fields in:
function Row_Import(&$row, $cnt) {
unset($row[2]);
return TRUE;
}
In this case I get:
Warning: array_combine(): Both parameters should have an equal number of elements in …lineas_list.php on line 2052 ($row = array_combine($headers, $values)
Warning: Invalid argument supplied for foreach() in…lineas_list.php on line 2158 (// Check field values foreach ($row as $name => $value) {…)
I’ve tried too:
function Row_Import(&$row, $cnt) {
$ori = array_slice($row, 0); // Clone
$row = ; // Clear
$row[“id”] = $ori[0];
$row[“item”] = $ori[1];
$row[“qty”] = $ori[3];
$row[“serial”] = $ori[4];
//I’ve tried too with indexex, row[“0”], row[“1”], etc…
return TRUE;
}
I get:
array_combine(): Both parameters should have an equal number of elements in …lineas_list.php on line 2052 ($row = array_combine($headers, $values)
Warning: array_slice() expects parameter 1 to be array, boolean given in…lineas_list.php on line 2716 ($ori = array_slice($row, 0); // Clone)
So, in both cases it seems I can’t get a right row array, that match with the headers.
I’ve tryed var_dump, but, as said in the above posts, I can’t get the values, not sure if it’s due to the modal form.
Thanks in advance.