This extension reads analysis data from an Excel workbook and fills specific tables in a Word template, producing a new report.
Inputs (from ReportToResultArgs):
ExcelFilePath (xlsx): Path to the source Excel file
WordTemplatePath (docx): Path to the Word template
Run behavior (from ReportToResultCommand):
- Validates both input files exist
- Reads the first sheet of the Excel after skipping the first 6 rows (row 7 is treated as header)
- Copies the template into the same directory, output name:
Updated_existing_document.docx
- Opens the document and searches for tables by headings:
- "Tabell 6:" (asbestos)
- "Tabell 16:" (vinyl/linoleum)
- "Tabell 27:" (paint/puss and concrete) — required
Data interpretation:
- Sample type is inferred from sample name text:
- Contains "betong" → concrete
- Contains "maling" or "puss" → paint/plaster
- Contains "vinyl" or "linoleum" → vinyl/linoleum
- Numeric analysis values extracted per sample:
PCB7, As, Pb, Cd, Hg, Zn, Cr6, SCCP, MCCP
- Thresholds used: §14A-4, §14A-5, and hazardous waste limits
Word output details:
- Table 27 (required):
- Paint/puss rows first, then concrete rows
- Vertical merge in column 0 to group category labels ("Maling og puss", "Betong")
- Color coding by contamination level:
- Pink
FFC7CE: hazardous
- Orange
FFC000: above §14A-5 (paint) or contaminated (concrete)
- Light yellow
FFEB9C: above §14A-4
- White
FFFFFF: below thresholds
- Columns filled: [0] category, [1] location (empty), [2] material, [3] scope (empty), [4] sample name, [5] PCB7, [6] metals, [7] chloroparaffins, [8] image (empty), [9] comment
- Table 6 (optional):
- Adds asbestos samples, pink if "påvist"; otherwise white
- Columns filled: [0] location, [1] material, [2] scope, [3] sample, [4] image, [5] comment
- Table 16 (optional):
- Adds vinyl/linoleum samples, hazardous first
- Columns filled: [0] location, [1] material, [2] scope, [3] sample, [4] metals, [5] image, [6] comment
Comments:
- Paint/puss and concrete comments are built from template rows in Table 27 with placeholders replaced based on measured substances and thresholds.
- Asbestos comments: "Inneholder asbest (type…)" or "Ikke påvist asbest".
Outputs:
- Success:
Report created at: <template-dir>/Updated_existing_document.docx
- Common failures: missing Excel, missing template, empty/unreadable sheet, invalid Word structure, missing Table 27
Requirements:
- .NET 8 runtime
- Valid
.xlsx with header at row 7 and sample columns from column 3 onward
- Word
.docx containing headings "Tabell 6:", "Tabell 16:", and "Tabell 27:" with expected column counts