poi-tl icon indicating copy to clipboard operation
poi-tl copied to clipboard

列表渲染时,如果表达式后紧跟文字结果不符合预期

Open werfei opened this issue 2 years ago • 0 comments

Issue description

模板如下 图片 结果如下 图片

poi-tl version

all

Minimal test code to reproduce the issue

public static void main(String[] args) throws Exception {
        TestData testData = new TestData();
        testData.setList(new ArrayList<Item>());
        for (int i = 0; i < 10; i++) {
            Item item = new Item();
            item.setName("name_" + i);
            testData.getList().add(item);
        }
        XWPFTemplate template;
        try (InputStream inputStream = Files.newInputStream(Paths.get("./template.docx"))) {

            Configure config = Configure.builder()
                    .build();
            template = XWPFTemplate.compile(inputStream, config).render(testData);

        }
        try (OutputStream os = Files.newOutputStream(Paths.get("./result.docx"))) {
            template.writeAndClose(os);
        }
    }

    public static class TestData {
        private List<Item> list;

        public List<Item> getList() {
            return list;
        }

        public void setList(List<Item> list) {
            this.list = list;
        }


    }

    public static class Item {
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

Minimal Docx template file

template.docx

werfei avatar Jun 16 '22 11:06 werfei