PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → import data from Excel
import data from Excel
Iniciado por VEGEboss, dez., 23 2019 6:03 PM - 1 resposta
Membro registado
88 mensagems
Popularité : +2 (2 votes)
Publicado em dezembro, 23 2019 - 6:03 PM
hello folks

please consider this very small piece of code
HImportXLS(Shoes_Tag, My_Excel_File, 1, "", hImpTestDuplicates+hImpIgnoreFirstLine)
IF ErrorOccurred THEN
Error(HErrorInfo())
END


and the structure os the related table (I don't know if can be useful, anyway here it is)







my problem is: every time the code above is launched, Windev add ALL the rows of the Excel sheet without any regard to the Unique Key (DataNumero, the last row in the picture) defined inthe table structure.

1) the file Excel and the .FIC table has the same structure
2) at every run I don't receive any error message and the table is re-re-re-re-filled with ALL the Excel rows
3) I think that, when importing data, Windev has to do ALL the "dirty work", automatic fillng the keys and checking the index

Where am I doing wrong?
Publicado em dezembro, 27 2019 - 4:12 PM
Hi VEGEboss,

"hImpTestDuplicates" will only avoid to have duplicates if you use it with "hCopyAutoId" (hCopyAutoId+hImpTestDuplicates).
So this option won't help.

1) The easiest way to do it is to use "hImpCreation", all the rows of your file will be deleted and re-created.

2) If you want to import only the last rows. You have to use an intermediate file:
HImportXLS(Shoes_Tag_Intermediate, My_Excel_File, 1, "", hImpCreation+hImpIgnoreFirstLine)

When this intermediate file is created:
- Get the highest ID of "Shoes_Tag"
- Then, for all rows of "Shoes_Tag_Intermediate" where ID > Highest ID of "Shoes_Tag", HCopyRecord(Shoes_Tag,Shoes_Tag_Intermediate)

Could it help?

Regards

Olivier