mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
add ofd
This commit is contained in:
parent
3033114e06
commit
b91561efe6
@ -20,6 +20,7 @@
|
||||
* 【core 】 修正DateUtil.betweenXXX注释错误(issue#I28XGW@Gitee)
|
||||
* 【core 】 增加NioUtil
|
||||
* 【core 】 增加GanymedUtil
|
||||
* 【poi 】 增加OFD支持,OfdWriter
|
||||
|
||||
### Bug修复
|
||||
* 【cache 】 修复Cache中get重复misCount计数问题(issue#1281@Github)
|
||||
|
@ -18,7 +18,6 @@
|
||||
<properties>
|
||||
<!-- versions -->
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<xerces.version>2.12.0</xerces.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -42,9 +41,9 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>${xerces.version}</version>
|
||||
<groupId>org.ofdrw</groupId>
|
||||
<artifactId>ofdrw-full</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
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;
|
Loading…
x
Reference in New Issue
Block a user