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 】 修正DateUtil.betweenXXX注释错误(issue#I28XGW@Gitee)
|
||||||
* 【core 】 增加NioUtil
|
* 【core 】 增加NioUtil
|
||||||
* 【core 】 增加GanymedUtil
|
* 【core 】 增加GanymedUtil
|
||||||
|
* 【poi 】 增加OFD支持,OfdWriter
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【cache 】 修复Cache中get重复misCount计数问题(issue#1281@Github)
|
* 【cache 】 修复Cache中get重复misCount计数问题(issue#1281@Github)
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<!-- versions -->
|
<!-- versions -->
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<xerces.version>2.12.0</xerces.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -42,9 +41,9 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xerces</groupId>
|
<groupId>org.ofdrw</groupId>
|
||||||
<artifactId>xercesImpl</artifactId>
|
<artifactId>ofdrw-full</artifactId>
|
||||||
<version>${xerces.version}</version>
|
<version>1.7.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</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