-
文本测试
-
@Author: Liziba
-
@Date: 2021/6/24 21:49
*/
public class DocTest {
public static void main(String[] args) throws IOException {
String filePath = “D:\poi-tl\textTest.docx”;
String targetPath = “D:\poi-tl\textTestTarget.docx”;
XWPFTemplate template = XWPFTemplate.compile(filePath).render(
new HashMap<String, Object>() {
{
put(“name”, “测试”);
put(“author”, Texts.of(“Liziba”).color(“000000”).create());
put(“link”, Texts.of(“百度”).link(“https://baidu.com”).create());
put(“anchor”, Texts.of(“anchortxt”).anchor(“appendix1”).create());
}
});
template.writeAndClose(new FileOutputStream(targetPath));
}
}
测试结果
4.2 图片
标签
{{@var}}
数据模型
-
String:图片url或者本地路径。默认使用图片自身尺寸
-
PictureRenderData
测试模板
测试代码
package com.lizba.poi;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.PictureType;
import com.deepoove.poi.data.Pictures;
import com.deepoove.poi.data.Texts;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
/**
-
-
图片测试
-
@Author: Liziba
-
@Date: 2021/6/24 21:49
*/
public class PictureTest {
public static void main(String[] args) throws IOException {
String filePath = “D:\poi-tl\pictureTest.docx”;
String targetPath = “D:\poi-tl\pictureTest2.docx”;
String picPath = “D:\poi-tl\pic.jpg”;
XWPFTemplate template = XWPFTemplate.compile(filePath).render(
new HashMap<String, Object>() {
{
// 方法一、图片路径(原大小)
put(“picture”, picPath);
// 方法二、指定图片大小
put(“picture”, Pictures.ofLocal(picPath).size(420,350).center().create());
// 方法三、图片流
put(“picture”, Pictures.ofStream(new FileInputStream(picPath), PictureType.JPEG)
.size(420,350).create());
// 针对网络图片、SVG图片、Java图片都有处理
}
});
template.writeAndClose(new FileOutputStream(targetPath));
}
}
测试结果
4.3 表格
标签
{{#var}}
数据模型
- TableRenderData
测试模板
测试代码
package com.lizba.poi;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
/**
-
-
列表测试
-
@Author: Liziba
-
@Date: 2021/6/24 21:49
*/
public class TableTest {
public static void main(String[] args) throws IOException {
String filePath = “D:\poi-tl\tableTest.docx”;
String targetPath = “D:\poi-tl\tableTest2.docx”;
// 表头
RowRenderData tableHead = Rows.of(“姓名”, “性别”, “地址”, “微信公众号”).center().bgColor(“4472c4”).create();
// 第一行
RowRenderData row1 = Rows.create(“张三”, “男”, “广东深圳”, “liziba_98”);
// 第二行
RowRenderData row2 = Rows.create(“李四”, “男”, “广东深圳”, “liziba_98”);
// 合并第一行和第二行的第二列与第三列
MergeCellRule rule = MergeCellRule.builder().map(MergeCellRule.Grid.of(1, 1), MergeCellRule.Grid.of(2, 1))
.map(MergeCellRule.Grid.of(1, 2), MergeCellRule.Grid.of(2, 2)).build();
XWPFTemplate template = XWPFTemplate.compile(filePath).render(
new HashMap<String, Object>() {
{
put(“table”, Tables.of(tableHead, row1, row2).mergeRule(rule).center().create());
}
});
template.writeAndClose(new FileOutputStream(targetPath));
}
}
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

最后
只要是程序员,不管是Java还是Android,如果不去阅读源码,只看API文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。
真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。
腾讯、字节跳动、阿里、百度等BAT大厂 2019-2021面试真题解析
资料太多,全部展示会影响篇幅,暂时就先列举这些部分截图
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!
PI文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。
真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。
[外链图片转存中…(img-8NqgFg6c-1711870040480)]
腾讯、字节跳动、阿里、百度等BAT大厂 2019-2021面试真题解析
[外链图片转存中…(img-Y9R6CE5m-1711870040480)]
资料太多,全部展示会影响篇幅,暂时就先列举这些部分截图