Někdy při inicializaci dokumentu 4D View Pro potřebujete v něm najít některé hodnoty nebo značky a nahradit je daty vydanými ze 4D. Nyní je to hračka díky funkci VP Find příkaz. Díky tomuto příkazu můžete najít data, vzorec nebo značku a nahradit je v celém listu nebo jen v jeho určité části!
Zjistíme, jak na to.
Příkaz VP Find Příkaz umožňuje vyhledat textovou hodnotu v určeném rozsahu v textu, vzorcích nebo značkách dokumentu 4D View Pro.
Chcete-li například vyhledat první výskyt slova „Celkem“ v textu buněk s ohledem na velikost písmen:
$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"))
Nyní můžete hledání upřesnit a najít všechny buňky obsahující slovo „Celkem“ pomocí příkazu all Vlastnost:
$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"))
- Pokud chcete provést vyhledávání pro „Total“ bez zohlednění velikosti písmen, stačí upravit příkaz flags vlastnost:
$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"))
- Pokud chcete nahradit všechna nalezená slova „Total“ slovem „4D“, přidejte parametr s nahrazovaným textem:
$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"))
To jsou samozřejmě jen některé z možností, které umožňuje vlastnost VP Find příkaz.
Další informace najdete v centru dokumentů, kde se dozvíte více, například jak vyhledávat hodnoty pomocí zástupných znaků, vyhledávat ve vzorcích a mnoho dalšího.