Comments (4)
把模板的样式附上来看看。
from poi-tl.
模板如下:
table2.docx
测试代码如下:
`Configure plugin = Configure.createDefault().plugin('$', new CustomTableRenderPolicy());
XWPFTemplate template = XWPFTemplate.compile("/Users/Arthur/Desktop/table2.docx",
plugin);
Map<String, Object> map=new HashMap<>();
List<Object> tableRows_kcb = new ArrayList<>();
tableRows_kcb.add("2017年11月1日09:00-10:30;课程1;1;张三");
tableRows_kcb.add("2017年11月1日11:00-12:30;课程2;1;张三");
tableRows_kcb.add("2017年11月1日14:00-15:30;课程3;1;张三");
map.put("kcb", new TableRenderData(new ArrayList<RenderData>() {{
add(new TextRenderData("培训时间"));
add(new TextRenderData("课程名称"));
add(new TextRenderData("课时"));
add(new TextRenderData("教师名称"));
}}, tableRows_kcb));
template.render(map);
String fileName = UUID.randomUUID().toString() + ".docx";
Path path = Paths.get("/tmp", fileName);
try (FileOutputStream out = new FileOutputStream(path.toString())) {
template.write(out);
out.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(path);`
比较费解的是,在我上传附件前想让模板变得只够简单,就删掉了内嵌表格前的内容,结果能正常生成表格。删减后的如下:
table.docx
from poi-tl.
@xingya771 在计算元素的时候越界了,原因是在一个单元格内元素过多。
- 下一个版本将会修复。
- 旧版本可以考虑把表格再拆分成三行,{{#kcb}}单独在一个单元格内,然后去除单元格的上下边框,这样展现的样式和你想要的是一样的。你可以试试这个方法。
from poi-tl.
@Sayi 万分感谢,刚试了下已经可以了
from poi-tl.
Related Issues (20)
- 根据条件动态删除表格行 HOT 2
- CVE-2023-6378、CVE-2022-44729 这两个漏洞是否可以升级一下? HOT 1
- 填充带有括号的标签,填充不上。 HOT 6
- 图片签章问题 HOT 1
- 设置某个表格在新的一页生成,而不是紧跟着前面的内容 HOT 1
- 单系列图表组合不支持
- 关于文章标题嵌套的问题,遍历树形结构(list嵌套list) HOT 1
- LoopRowTableRenderPolicy插件中SpringEL的使用问题 HOT 7
- 请问如何实现表格多行循环 HOT 1
- Markdown tag inside block pairs is not working HOT 2
- 怎么在表格中循环插入表格数据 HOT 1
- 文本内容中的换行符未被正确渲染为不同的段落
- 渲染标签失败
- 报表标签渲染失败
- poi-tl再发新版本时,能把poi-tl-plugin-markdown的版本改成1.0.4版本吗?
- paragraph.getCTP().removeR(2),发生java.lang.IndexOutOfBoundsException HOT 1
- 如何渲染模板中的公式 HOT 1
- 是否支持导出word中的表格实现每页都输出表头信息? HOT 1
- 如何实现表格行循环嵌套循环 HOT 1
- 报告中图表生成报错:SAXParseException: Premature end of file. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poi-tl.