关于链式调用的写法,参考:poi-tl java插件
    1:需要的类: 概述类 概述类的静态内部类-构建数据的类,数据类
    概述类
    {
    STATIC OF() —返回构建数据的静态内部类
    构建数据的静态内部类{
    对应数据属性私有变量1:
    对应数据属性私有变量2:
    实例方法设置数据属性1:{
    }
    实例方法设置数据属性2{
    }
    //create返回真正的数据对象
    CREATE:{
    new 数据类()
    数据类属性1 = 私有变量1
    数据类属性2 = 私有变量2
    RETURN 数据类
    }
    }
    }

    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //

    //Texts
    package com.deepoove.poi.data;

    import com.deepoove.poi.data.style.Style;
    import org.apache.poi.xwpf.usermodel.UnderlinePatterns;

    public final class Texts {
    private Texts() {
    }

    1. public static Texts.TextBuilder of(String text) {<br /> return new Texts.TextBuilder(text);<br /> }
    2. public static class TextBuilder implements RenderDataBuilder<TextRenderData> {<br /> private String text;<br /> private Style style;<br /> private String url;<br /> private String bookmark;
    3. private TextBuilder(String text) {<br /> this.text = text;<br /> }
    4. public Texts.TextBuilder style(Style style) {<br /> this.style = style;<br /> return this;<br /> }
    5. public Texts.TextBuilder color(String color) {<br /> if (null != this.style) {<br /> this.style.setColor(color);<br /> } else {<br /> this.style = Style.builder().buildColor(color).build();<br /> }
    6. return this;<br /> }
    7. public Texts.TextBuilder bold() {<br /> if (null != this.style) {<br /> this.style.setBold(true);<br /> } else {<br /> this.style = Style.builder().buildBold().build();<br /> }
    8. return this;<br /> }
    9. public Texts.TextBuilder italic() {<br /> if (null != this.style) {<br /> this.style.setItalic(true);<br /> } else {<br /> this.style = Style.builder().buildItalic().build();<br /> }
    10. return this;<br /> }
    11. public Texts.TextBuilder sup() {<br /> if (null != this.style) {<br /> this.style.setVertAlign("superscript");<br /> } else {<br /> this.style = Style.builder().buildSuper().build();<br /> }
    12. return this;<br /> }
    13. public Texts.TextBuilder sub() {<br /> if (null != this.style) {<br /> this.style.setVertAlign("subscript");<br /> } else {<br /> this.style = Style.builder().buildSub().build();<br /> }
    14. return this;<br /> }
    15. public Texts.TextBuilder fontSize(double fontSize) {<br /> if (null != this.style) {<br /> this.style.setFontSize(fontSize);<br /> } else {<br /> this.style = Style.builder().buildFontSize(fontSize).build();<br /> }
    16. return this;<br /> }
    17. public Texts.TextBuilder fontFamily(String fontFamily) {<br /> if (null != this.style) {<br /> this.style.setFontFamily(fontFamily);<br /> } else {<br /> this.style = Style.builder().buildFontFamily(fontFamily).build();<br /> }
    18. return this;<br /> }
    19. public Texts.TextBuilder link(String url) {<br /> this.url = url;<br /> if (null == this.style) {<br /> this.style = Style.builder().buildColor("0000FF").buildUnderlinePatterns(UnderlinePatterns.SINGLE).build();<br /> }
    20. return this;<br /> }
    21. public Texts.TextBuilder bookmark(String name) {<br /> this.bookmark = name;<br /> return this;<br /> }
    22. public Texts.TextBuilder mailto(String address, String subject) {<br /> StringBuilder sb = new StringBuilder(128);<br /> sb.append("mailto:").append(address).append("?subject=").append(subject);<br /> return this.link(sb.toString());<br /> }
    23. public Texts.TextBuilder anchor(String anchorName) {<br /> StringBuilder sb = new StringBuilder(32);<br /> sb.append("anchor:").append(anchorName);<br /> return this.link(sb.toString());<br /> }
    24. public TextRenderData create() {<br /> TextRenderData data = null;<br /> if (null != this.url) {<br /> data = new HyperlinkTextRenderData(this.text, this.url);<br /> } else if (null != this.bookmark) {<br /> data = new BookmarkTextRenderData(this.text, this.bookmark);<br /> } else {<br /> data = new TextRenderData(this.text);<br /> }
    25. ((TextRenderData)data).setStyle(this.style);<br /> return (TextRenderData)data;<br /> }<br /> }<br />}

    //TextRenderData
    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //

    package com.deepoove.poi.data;

    import com.deepoove.poi.data.style.Style;

    public class TextRenderData implements RenderData {
    private static final long serialVersionUID = 1L;
    protected Style style;
    protected String text;

    1. public TextRenderData() {<br /> }
    2. public TextRenderData(String text) {<br /> this.text = text;<br /> }
    3. public TextRenderData(String color, String text) {<br /> this.style = Style.builder().buildColor(color).build();<br /> this.text = text;<br /> }
    4. public TextRenderData(String text, Style style) {<br /> this.style = style;<br /> this.text = text;<br /> }
    5. public Style getStyle() {<br /> return this.style;<br /> }
    6. public void setStyle(Style style) {<br /> this.style = style;<br /> }
    7. public String getText() {<br /> return this.text;<br /> }
    8. public void setText(String text) {<br /> this.text = text;<br /> }
    9. public String toString() {<br /> return this.text;<br /> }<br />}

    //
    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //

    package com.deepoove.poi.data;

    import java.io.Serializable;

    public interface RenderData extends Serializable {
    }

    //Texts.of(“□”).create()返回数据对象实例,数据对象可以继续添加内部对象
    //使用的方式
    Texts.of(“□”).fontFamily(“仿宋”).create();
    //Texts.of(“□”) 返回构建数据的静态内部类
    //Texts.of(“□”).fontFamily(“仿宋”) 依然是返回构建数据的静态内部类

    ParagraphRenderData paragraph = new ParagraphRenderData();
    paragraph.addText(map.get(picDescKey).toString() + “\n”);
    String fileName = ApplicationConfig.uploadPath + map.get(relativePicPathKey);
    paragraph.addPicture((Pictures.ofLocal(fileName)).size(picWidth, picHeight).create());
    listCell.add(Cells.of().create().addParagraph(paragraph)); //这里是数据实例
    if (listCell.size() % columnCount == 0) {
    listRow.add(Rows.of(listCell.toArray(new CellRenderData[listCell.size()])).create());
    listCell = new ArrayList();
    }
    }