OfficeServer/create-new-table-template.js
dgsoft 5371d5e479 Add WebDAV integration and template improvements
 Frontend-Verbesserungen:
- WebDAV-Integration für direktes Template-Bearbeiten
- 'In Word öffnen' Button für ms-word: URLs
- Verbesserte Template-Karten mit Tag-Informationen
- WebDAV-Info-Sektion mit Anleitungen
- Korrigierte API-Endpunkte für docxtemplater

🔧 Template-Updates:
- Alle Templates auf docxtemplater-Syntax aktualisiert
- create-*-fixed.js Scripts für korrekte {tag} Syntax
- Entfernt alte ++tag++ und ++INS++ Syntax
- Neue create-new-table-template.js für echte Loops

🌐 WebDAV-Features:
- Direkter Template-Download über /webdav/templates/
- Template-Bearbeitung in Word möglich
- Automatische Speicherung über WebDAV
- Fallback auf Download bei Word-Problemen

📊 Template-Syntax-Migration:
- {variable} statt ++variable++
- {#array}{field}{/array} statt ++INS array++
- Echte dynamische Tabellen ohne fixe Indizes
- Verbesserte Tag-Erkennung und Analyse
2025-10-01 22:27:29 +02:00

67 lines
3.3 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell } = require('docx');
async function createTableTemplate() {
const doc = new Document({
sections: [{
properties: {},
children: [
new Paragraph({
children: [
new TextRun({
text: "DYNAMISCHES TABELLEN-TEMPLATE",
bold: true,
size: 32,
}),
],
}),
new Paragraph({ children: [new TextRun({ text: "" })] }),
new Paragraph({ children: [new TextRun({ text: "Projekt: {projekt}", bold: true })] }),
new Paragraph({ children: [new TextRun({ text: "Datum: {datum}" })] }),
new Paragraph({ children: [new TextRun({ text: "Ersteller: {ersteller}" })] }),
new Paragraph({ children: [new TextRun({ text: "" })] }),
new Paragraph({
children: [new TextRun({ text: "MITARBEITERLISTE:", bold: true, size: 24 })],
}),
new Table({
rows: [
new TableRow({
children: [
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "Nr.", bold: true })] })] }),
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "Name", bold: true })] })] }),
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "Position", bold: true })] })] }),
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "E-Mail", bold: true })] })] }),
],
}),
new TableRow({
children: [
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "{#mitarbeiter}{nr}" })] })] }),
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "{name}" })] })] }),
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "{position}" })] })] }),
new TableCell({ children: [new Paragraph({ children: [new TextRun({ text: "{email}{/mitarbeiter}" })] })] }),
],
}),
],
}),
new Paragraph({ children: [new TextRun({ text: "" })] }),
new Paragraph({
children: [
new TextRun({
text: "Status: {status}",
bold: true
})
]
}),
],
}],
});
const buffer = await Packer.toBuffer(doc);
const outputPath = path.join(__dirname, 'templates', 'tabellen-template.docx');
fs.writeFileSync(outputPath, buffer);
console.log('✅ Tabellen-Template mit docxtemplater Loop-Syntax erstellt');
}
createTableTemplate().catch(console.error);