itext能导出excel吗?如何导出
发布网友
发布时间:2022-04-27 08:05
我来回答
共2个回答
热心网友
时间:2022-06-28 20:47
可以,代码如下:
//创建ExcelEntity
import java.io.OutputStream;
import java.util.List;
public class ExcelEntity<T> {
private String title = "报表标题";
private String[] headers;
private List<T> dataset;
private OutputStream os;
private boolean hasComment = false;
private String commentContent = "report";
private String commentAuthor = "Galo";
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String[] getHeaders() {
return headers;
}
public void setHeaders(String[] headers) {
this.headers = headers;
}
public List<T> getDataset() {
return dataset;
}
public void setDataset(List<T> dataset) {
this.dataset = dataset;
}
public OutputStream getOs() {
return os;
}
public void setOs(OutputStream os) {
this.os = os;
}
public boolean isHasComment() {
return hasComment;
}
public void setHasComment(boolean hasComment) {
this.hasComment = hasComment;
}
public String getCommentContent() {
return commentContent;
}
public void setCommentContent(String commentContent) {
this.commentContent = commentContent;
}
public String getCommentAuthor() {
return commentAuthor;
}
public void setCommentAuthor(String commentAuthor) {
this.commentAuthor = commentAuthor;
}
}
热心网友
时间:2022-06-28 20:47
要导出excel,你该考虑 jXLS或者POI,而不是iText,这个只能生成PDF/RTF/HTML
或者简单地把html的后缀改成xls
当然生成openxml的xlsx的方式就更多了,你自己搜下开源实现吧。