package com.hotent.util.wordexcelutils;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class DocumentProcessorExample {
    public static void main(String[] args) {
        // Word文档处理示例
        processWordExample();

        // Excel文档处理示例
        //processExcelExample();
    }

    private static void processWordExample() {
        // 文本替换映射
        Map<String, String> textReplacements = new HashMap<>();
        textReplacements.put("{价格主管部门或成本调查机构}", "张三");
        textReplacements.put("{送达文书名称}", "2023-10-01");
        textReplacements.put("{送达文书文号}", "某某公司");

        // 图片替换映射
        //Map<String, String> imageReplacements = new HashMap<>();
        //imageReplacements.put("{signature}", "path/to/signature.png");
        //imageReplacements.put("{logo}", "path/to/logo.jpg");

        // 处理Word文档
        DocumentProcessor.processWordDocument(
            "C:\\Users\\123\\Desktop\\送  达  回  证_20251105182242_856.docx",
            "C:\\Users\\123\\Desktop\\output.docx",
            textReplacements,
            new LinkedHashMap<>()
        );
    }

    private static void processExcelExample() {
        // 图片位置映射
        Map<String, String> imageMappings = new HashMap<>();
        imageMappings.put("B2", "path/to/chart.png");
        imageMappings.put("D5", "path/to/photo.jpg");

        // 处理Excel文档
        DocumentProcessor.processExcelDocument(
            "template.xlsx",
            "output.xlsx",
            imageMappings
        );
    }

    private static void processExcelWithPlaceholdersExample() {
        // 文本替换映射
        Map<String, String> textReplacements = new HashMap<>();
        textReplacements.put("{name}", "张三");
        textReplacements.put("{date}", "2023-10-01");
        textReplacements.put("{department}", "技术部");

        // 图片位置映射
        Map<String, String> imageMappings = new HashMap<>();
        imageMappings.put("B2", "path/to/chart.png");
        imageMappings.put("D5", "path/to/photo.jpg");

        // 处理Excel文档（包含文本替换和图片插入）
        DocumentProcessor.processExcelWithPlaceholders(
                "template.xlsx",
                "output_with_placeholders.xlsx",
                textReplacements,
                imageMappings
        );
    }

}
