MSWordx
mswordx replace <source> <destination> <jsonKeyValue>
Description
Replace texts in a WordX document.
Replace texts in a WordX document.
Parameters
source: The source path - string - required
destination: The destination path - string - required
jsonKeyValue: The JSON of findtext/replacetext pairs - string - required
source: The source path - string - required
destination: The destination path - string - required
jsonKeyValue: The JSON of findtext/replacetext pairs - string - required
admin
json load "findReplace" "{}"; # language for @trad: ; json iobject "findReplace" / "lang" "fr" STR; # @val:nb ; json iobject "findReplace" / "nb" "12" STR; # @val:client.name, @val:client.city ; json iobject "findReplace" / "client" "{}" OBJ; json iobject "findReplace" /client "name" "Dupont" STR; json iobject "findReplace" /client "city" "Saint-Denis" STR; # @tab:products:ref/lib/prix/qte + @imgtab:products:photo ; json iobject "findReplace" / "products" "[]" ARRAY; json load "p1" "{}"; json iobject "p1" / "ref" "A001" STR; json iobject "p1" / "lib" "Chaise" STR; json iobject "p1" / "prix" "50" STR; json iobject "p1" / "qte" "2" STR; json iobject "p1" / "photo" (file b64_read "/Users/jimmitry/Desktop/ccc.png") STR; json iarray "findReplace" /products (json doc "p1") OBJ; json load "p2" "{}"; json iobject "p2" / "ref" "A002" STR; json iobject "p2" / "lib" "Table" STR; json iobject "p2" / "prix" "200" STR; json iobject "p2" / "qte" "1" STR; json iobject "p2" / "photo" "{}" OBJ; json iobject "p2" /photo "data" (file b64_read "/Users/jimmitry/Desktop/ccc.png") STR; json iobject "p2" /photo "width" "100" INT; json iobject "p2" /photo "height" "100" INT; json iarray "findReplace" /products (json doc "p2") OBJ; # @img:logo ; json iobject "findReplace" / "logo" (file b64_read "/Users/jimmitry/Desktop/aaa.png") STR; # @img:photo_product ; json iobject "findReplace" / "photo_product" "{}" OBJ; json iobject "findReplace" /photo_product "data" (file b64_read "/Users/jimmitry/Desktop/bbb.png") STR; json iobject "findReplace" /photo_product "width" "300" INT; json iobject "findReplace" /photo_product "height" "200" INT; mswordx replace "/Users/jimmitry/Desktop/word1.docx" "/Users/jimmitry/Desktop/word2.docx" (json doc "findReplace");
mentdb
1
mswordx replace <mainSource> <loopSource> <destination> <jsonKeyValue>
Description
Replace texts in a WordX document with loop options.
Replace texts in a WordX document with loop options.
Parameters
mainSource: The main source path - string - required
loopSource: The loop source path - string - required
destination: The destination path - string - required
jsonKeyValue: The JSON of findtext/replacetext pairs - string - required
mainSource: The main source path - string - required
loopSource: The loop source path - string - required
destination: The destination path - string - required
jsonKeyValue: The JSON of findtext/replacetext pairs - string - required
admin
# ============================================================================; # Root JSON; # ============================================================================; json load "findReplace" "{}"; # language for @trad: tags ; json iobject "findReplace" / "lang" "fr" STR; # ----------------------------------------------------------------------------; # GLOBAL tags of the main (resolved with the root, after @loop: expansion); # ----------------------------------------------------------------------------; # @val:rapport.title, @val:rapport.date; json iobject "findReplace" / "rapport" "{}" OBJ; json iobject "findReplace" /rapport "title" "Rapport mensuel - Clients" STR; json iobject "findReplace" /rapport "date" "2026-05-19" STR; # @img:logo_societe (header logo of the main, distinct from each sheet's logo); json iobject "findReplace" / "logo_societe" (file b64_read "tools/mswordx/aaa.png") STR; # ----------------------------------------------------------------------------; # @loop:fiches: the list that will be expanded by injecting word1.docx; # Each item MUST have the same structure as the JSON of the 1st example,; # because word1.docx is used as the loopSource.; # ----------------------------------------------------------------------------; json iobject "findReplace" / "fiches" "[]" ARRAY; # ============================================================================; # Sheet 1 (= a word1.docx filled with this data); # ============================================================================; json load "fiche1" "{}"; # @val:nb; json iobject "fiche1" / "nb" "12" STR; # @val:client.name, @val:client.city; json iobject "fiche1" / "client" "{}" OBJ; json iobject "fiche1" /client "name" "Dupont" STR; json iobject "fiche1" /client "city" "Saint-Denis" STR; # @tab:products:* + @imgtab:products:photo; json iobject "fiche1" / "products" "[]" ARRAY; json load "f1_p1" "{}"; json iobject "f1_p1" / "ref" "A001" STR; json iobject "f1_p1" / "lib" "Chaise" STR; json iobject "f1_p1" / "prix" "50" STR; json iobject "f1_p1" / "qte" "2" STR; json iobject "f1_p1" / "photo" (file b64_read "tools/mswordx/ccc.png") STR; json iarray "fiche1" /products (json doc "f1_p1") OBJ; json load "f1_p2" "{}"; json iobject "f1_p2" / "ref" "A002" STR; json iobject "f1_p2" / "lib" "Table" STR; json iobject "f1_p2" / "prix" "200" STR; json iobject "f1_p2" / "qte" "1" STR; json iobject "f1_p2" / "photo" "{}" OBJ; json iobject "f1_p2" /photo "data" (file b64_read "tools/mswordx/ccc.png") STR; json iobject "f1_p2" /photo "width" "100" INT; json iobject "f1_p2" /photo "height" "100" INT; json iarray "fiche1" /products (json doc "f1_p2") OBJ; # @img:logo (logo inside the sheet); json iobject "fiche1" / "logo" (file b64_read "tools/mswordx/aaa.png") STR; # @img:photo_product; json iobject "fiche1" / "photo_product" "{}" OBJ; json iobject "fiche1" /photo_product "data" (file b64_read "tools/mswordx/bbb.png") STR; json iobject "fiche1" /photo_product "width" "300" INT; json iobject "fiche1" /photo_product "height" "200" INT; # Add sheet 1 to the "fiches" array; json iarray "findReplace" /fiches (json doc "fiche1") OBJ; # ============================================================================; # Sheet 2 (another client, other products); # ============================================================================; json load "fiche2" "{}"; json iobject "fiche2" / "nb" "5" STR; json iobject "fiche2" / "client" "{}" OBJ; json iobject "fiche2" /client "name" "Martin" STR; json iobject "fiche2" /client "city" "Saint-Paul" STR; json iobject "fiche2" / "products" "[]" ARRAY; json load "f2_p1" "{}"; json iobject "f2_p1" / "ref" "B100" STR; json iobject "f2_p1" / "lib" "Lampe" STR; json iobject "f2_p1" / "prix" "75" STR; json iobject "f2_p1" / "qte" "3" STR; json iobject "f2_p1" / "photo" (file b64_read "tools/mswordx/ccc.png") STR; json iarray "fiche2" /products (json doc "f2_p1") OBJ; json iobject "fiche2" / "logo" (file b64_read "tools/mswordx/aaa.png") STR; json iobject "fiche2" / "photo_product" "{}" OBJ; json iobject "fiche2" /photo_product "data" (file b64_read "tools/mswordx/bbb.png") STR; json iobject "fiche2" /photo_product "width" "300" INT; json iobject "fiche2" /photo_product "height" "200" INT; json iarray "findReplace" /fiches (json doc "fiche2") OBJ; # ============================================================================; # Call: main + loop -> result; # ============================================================================; mswordx replace "tools/mswordx/wordMain.docx" "tools/mswordx/word1.docx" "tools/mswordx/wordResult.docx" (json doc "findReplace");
mentdb
1
