Last active
July 28, 2025 15:24
-
-
Save eugrus/d46b581d2bea3aae8b1362c8ab3762ab to your computer and use it in GitHub Desktop.
Platzhalter anhand einer Tabelle füllen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
pd.read_excel('PH.xlsx').to_json('PH.json', orient='records', indent=4, force_ascii=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([Parameter(Mandatory=$true)][string]$Mandant) | |
Import-Module .\iurfnlib.psm1 # https://github.com/eugrus/iurfnlib | |
# Platzhalter für kurze Eintragungen (bis 255 Zeichen) anhand JSON ersetzen | |
$json = Get-Content -Path ".\PH.json" -Raw | ConvertFrom-Json | |
foreach ($entry in $json) { | |
$pl = $entry.PH.Trim() | |
$val = $entry.$Mandant | |
if ($val) { | |
ReplaceInWord $pl $val | |
} | |
} | |
# Längere Bausteine für einige Platzhalter aus dem Ordner holen | |
if (Test-Path "$PSScriptRoot\$Mandant") { | |
$files = Get-ChildItem -Path "$PSScriptRoot\$Mandant" -Include "*.docx", "*.rtf" -Recurse | |
foreach ($file in $files) { | |
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name) | |
$placeholder = "ph" + $fileName | |
FillSpaceholderInWord $placeholder $file.FullName | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment