Git Product home page Git Product logo

Comments (4)

Sayi avatar Sayi commented on May 15, 2024

把模板的样式附上来看看。

from poi-tl.

xingya771 avatar xingya771 commented on May 15, 2024

模板如下:
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.

Sayi avatar Sayi commented on May 15, 2024

@xingya771 在计算元素的时候越界了,原因是在一个单元格内元素过多。

  1. 下一个版本将会修复。
  2. 旧版本可以考虑把表格再拆分成三行,{{#kcb}}单独在一个单元格内,然后去除单元格的上下边框,这样展现的样式和你想要的是一样的。你可以试试这个方法。

image

from poi-tl.

xingya771 avatar xingya771 commented on May 15, 2024

@Sayi 万分感谢,刚试了下已经可以了

from poi-tl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.