用docx4j操作word书签,在word书签中插入文本
用docx4j,jar出去word书签,在word书签中插入文本
源码可以通过以下链接查看:
https://github.com/xulp-mzl/xlp-core
https://github.com/xulp-mzl/xlp-third
https://download.csdn.net/download/x15179220203xlp/9920651
实例:
public static void main(String[] args) throws Docx4JException {
DocxBookmarkTemplate docxBookmarkTemplate = new DocxBookmarkTemplate("f:/12.docx");
docxBookmarkTemplate.beforeInsertText("title", "收拾2hj").afterInsertText("space", "哈哈2")
.replaceText("id", "yee ").replaceText("textBox", "哈哈").replaceText("content1", "ss是");
docxBookmarkTemplate.save(new File("f:/13.docx"));
docxBookmarkTemplate.close();
}
xlp-core 字符串操作工具
主要有简化字符串和集合数组的操作等
源码可以通过以下链接查看:
https://github.com/xulp-mzl/xlp-core
Json解析库JsonObject
https://download.csdn.net/download/x15179220203xlp/9920651
方便好用的json解析库,每个json元素都是一个JsonElement对象,通过这个对象,你可以很方便的从Json子类对象中得到你想要的值,不需要你进一步转换,用法如:
JsonObject jsonObject = new JsonObject (...);
在调用此对象的一些方法,可以方便的把数据放到JsonObject 对象中
通过jsonObject .getJsonElement(key)可以方便的得到JsonElement该对象,接着可以方便的得到你想要的数据
基于poi Excel导出
实例:import java.util.Date;
import org.xlp.annotation.ExcelOutputed;
public class Student {
@ExcelOutputed
private int id;
@ExcelOutputed("姓名")
private String name;
@ExcelOutputed("生日")
private Date timDate;
@ExcelOutputed
private boolean d;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getTimDate() {
return timDate;
}
public void setTimDate(Date timDate) {
this.timDate = timDate;
}
public boolean isD() {
return d;
}
public void setD(boolean d) {
this.d = d;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Student [id=").append(id).append(", name=")
.append(name).append(", timDate=").append(timDate)
.append(", d=").append(d).append("]");
return builder.toString();
}
}
public class Test(){
public static void main(String[] args) {
anno();
testMap();
}
}
public static void anno(){
Student student = new Student();
student.setId(1);
student.setName("张三;; ");
student.setTimDate(new Date());
Student student1 = new Student();
student1.setId(1);
student1.setName("张三1");
student1.setTimDate(new Date());
List<Student> list = new ArrayList<Student>();
list.add(student);
list.add(student1);System.out.println(list);
XLPExcelBean xlpExcel = new XLPExcelBean();
xlpExcel.setSheetDatasOfBeans(list);
xlpExcel.writeExcel("e:/xxx.xls");
}
public static void testMap(){
Map<String, Object> map = new HashMap<String, Object>();
map.put("qq", 12);
map.put("s=s", "=ass");
map.put("12", true);
map.put(null, null);
map.put("date", new Date());
map.put("现金", 20.365);
System.out.println(map.keySet().toString());
System.out.println(map.values().toArray()[0]);
System.out.println(Calendar.getInstance());
XLPExcel xlpExcel = new XLPExcel();
List<Map<String, Object>> arrayList = new ArrayList<Map<String,Object>>();
arrayList.add(map);
xlpExcel.setSheetDatas(arrayList);
xlpExcel.writeExcel(new File("e:/xx1.xls"));
}