mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add ofd
This commit is contained in:
42
hutool-poi/src/main/java/cn/hutool/poi/ofd/OfdWriter.java
Normal file
42
hutool-poi/src/main/java/cn/hutool/poi/ofd/OfdWriter.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package cn.hutool.poi.ofd;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import org.ofdrw.font.Font;
|
||||
import org.ofdrw.layout.OFDDoc;
|
||||
import org.ofdrw.layout.element.Div;
|
||||
import org.ofdrw.layout.element.Paragraph;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.Serializable;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class OfdWriter implements Serializable, Closeable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Path destFile;
|
||||
private final OFDDoc doc;
|
||||
|
||||
public OfdWriter(Path file){
|
||||
this.destFile = file;
|
||||
this.doc = new OFDDoc(file);
|
||||
}
|
||||
|
||||
public OfdWriter addText(Font font, String... texts){
|
||||
final Paragraph paragraph = new Paragraph();
|
||||
paragraph.setDefaultFont(font);
|
||||
for (String text : texts) {
|
||||
paragraph.add(text);
|
||||
}
|
||||
return add(paragraph);
|
||||
}
|
||||
|
||||
public OfdWriter add(Div div){
|
||||
this.doc.add(div);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
IoUtil.close(this.doc);
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 开放版式文档(Open Fixed-layout Document )封装,基于ofdrw(https://gitee.com/Trisia/ofdrw)
|
||||
*
|
||||
* @author looly
|
||||
*/
|
||||
package cn.hutool.poi.ofd;
|
Reference in New Issue
Block a user