Parfois, lorsque vous initialisez un document 4D View Pro, vous devez trouver certaines valeurs ou balises dans celui-ci et les remplacer par des données issues de 4D. C’est désormais un jeu d’enfant avec la commande VP Find . Grâce à cette commande, vous pouvez trouver des données, une formule ou une balise et les remplacer dans toute la feuille ou seulement une partie spécifique de celle-ci !
Découvrons comment.
La commande VP Find vous permet de rechercher une valeur de texte dans une plage désignée dans le texte, les formules ou les balises d’un document 4D View Pro.
Par exemple, si vous voulez effectuer une recherche sensible à la casse pour la première occurrence du mot « Total » dans le texte des cellules :
$range:=VP All("ViewProArea")
// find the first cell that contains the word 'Total' in the current sheet
$result :=VP Find($range; "Total")
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor" ; "yellow"))
Maintenant, vous pouvez affiner votre recherche pour trouver toutes les cellules contenant « Total » en utilisant la propriété all en utilisant la propriété » Total » :
$range:=VP All("ViewProArea")
$condition :=New object
// Search in all values in the range
$condition .all:=True
// Find all cells containing the word 'Total' in the current sheet
$result :=VP Find($range; "Total" ; $condition)
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor" ; "yellow"))
- Si vous souhaitez effectuer une recherche sur « Total » sans tenir compte de la casse, il suffit de modifier la propriété flags la propriété :
$range:=VP All("ViewProArea")
$condition :=New object
// Search the entire sheet
$condition .all:=True
// Search cells containing the word "Total" without considering the case
$condition .flags:=vk find flag ignore case
// Find all cells containing only the word 'Total' in the current sheet
$result :=VP Find($range; "Total" ; $condition)
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor" ; "yellow"))
- Si vous voulez remplacer tous les mots « Total » trouvés par « 4D », ajoutez un paramètre avec le texte de remplacement :
$range:=VP All("ViewProArea")
)
$condition :=New object
// Search the entire sheet
$condition .all:=True
// Search cells containing the word "Total" without considering the case
$condition .flags:=vk find flag ignore case
// Replace text in all cells containing only 'Total' with "4D"
$result :=VP Find($range; "Total" ; $condition; "4D")
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor" ; "yellow")
Bien entendu, ce ne sont là que quelques-unes des possibilités offertes par la commande VP Find de la commande.
Consultez le centre de documentation pour en savoir plus, notamment sur la recherche de valeurs à l’aide de caractères génériques, la recherche dans les formules, etc.