Skip to content

Instantly share code, notes, and snippets.

@eugrus
Last active July 28, 2025 15:24
Show Gist options
  • Save eugrus/d46b581d2bea3aae8b1362c8ab3762ab to your computer and use it in GitHub Desktop.
Save eugrus/d46b581d2bea3aae8b1362c8ab3762ab to your computer and use it in GitHub Desktop.
Platzhalter anhand einer Tabelle füllen
import pandas as pd
pd.read_excel('PH.xlsx').to_json('PH.json', orient='records', indent=4, force_ascii=False)
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