A veces, cuando inicializa un documento de 4D View Pro, necesita encontrar algunos valores o etiquetas en él y reemplazarlos con datos emitidos desde 4D. Ahora es muy fácil con el comando VP Find comando. Gracias a este comando, puede encontrar datos, una fórmula o una etiqueta y reemplazarla en toda la hoja o sólo en una parte específica de ella.
Descubramos cómo.
El comando VP Find te permite buscar un valor de texto dentro de un rango designado en el texto, las fórmulas o las etiquetas de un documento de 4D View Pro.
Por ejemplo, si desea realizar una búsqueda que distinga entre mayúsculas y minúsculas de la primera aparición de la palabra «Total» en el texto de las celdas:
$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"))
Ahora puedes refinar tu búsqueda para encontrar todas las celdas que contengan «Total» utilizando la propiedad all propiedad:
$range:=VP All("ViewProArea")
ckColor»; «yellow»))
$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("ba
- Si quieres realizar una búsqueda por «Total» sin tener en cuenta el caso, sólo tienes que modificar la propiedad flags propiedad:
$range:=VP All("ViewProArea")
«backColor»; «yellow»))
$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(
- Si desea sustituir todas las palabras «Total» encontradas por «4D», añada un parámetro con el texto de sustitución:
$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"))
Por supuesto, estas son sólo algunas de las posibilidades que permite el comando VP Find comando.
Para saber más, consulte el centro de documentación, por ejemplo, cómo buscar valores con comodines, buscar en fórmulas y mucho más.