You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.2 KiB

7 years ago
package com.alibaba.excel.metadata;
import java.util.List;
import com.alibaba.excel.event.Handler;
import com.alibaba.excel.write.handler.WriteHandler;
7 years ago
/**
* table
*
7 years ago
* @author jipengfei
*/
public class Table {
/**
* Starting from 1
7 years ago
*/
private Integer tableNo;
/**
* Writes the header relative to the existing contents of the sheet. Indexes are zero-based.
*/
private Integer writeRelativeHeadRowIndex;
7 years ago
/**
* You can only choose one of the {@link Table#head} and {@link Table#clazz}
7 years ago
*/
private List<List<String>> head;
/**
* You can only choose one of the {@link Table#head} and {@link Table#clazz}
7 years ago
*/
private Class clazz;
/**
* Need head
*/
private Boolean needHead;
7 years ago
/**
* Handle some extra logic. So far only for writing purposes {@link WriteHandler}
*
7 years ago
*/
private List<Handler> handler;
7 years ago
public Table(Integer sheetNo) {
this(sheetNo, 0, null, null, Boolean.TRUE);
}
public Table(Integer sheetNo, List<List<String>> head) {
this(sheetNo, 0, head, null, Boolean.TRUE);
}
public Table(Integer sheetNo, Class clazz) {
this(sheetNo, 0, null, clazz, Boolean.TRUE);
}
public Table(Integer tableNo, Integer writeRelativeHeadRowIndex, List<List<String>> head, Class clazz,
Boolean needHead) {
if (tableNo == null || tableNo < 1) {
throw new IllegalArgumentException("SheetNo must greater than 0");
}
if (writeRelativeHeadRowIndex == null || writeRelativeHeadRowIndex < 0) {
throw new IllegalArgumentException("WriteRelativeHeadRowIndex must greater than -1");
}
if (head != null && !head.isEmpty() && clazz != null) {
throw new IllegalArgumentException("Head and clazz fill in no more than one");
}
if (needHead == null) {
throw new IllegalArgumentException("NeedHead can not be null");
}
this.tableNo = tableNo;
this.writeRelativeHeadRowIndex = writeRelativeHeadRowIndex;
this.head = head;
this.clazz = clazz;
this.needHead = needHead;
7 years ago
}
public Integer getTableNo() {
return tableNo;
7 years ago
}
public void setTableNo(Integer tableNo) {
7 years ago
this.tableNo = tableNo;
}
public Integer getWriteRelativeHeadRowIndex() {
return writeRelativeHeadRowIndex;
7 years ago
}
public void setWriteRelativeHeadRowIndex(Integer writeRelativeHeadRowIndex) {
this.writeRelativeHeadRowIndex = writeRelativeHeadRowIndex;
7 years ago
}
public List<List<String>> getHead() {
return head;
}
public void setHead(List<List<String>> head) {
this.head = head;
}
public Class getClazz() {
return clazz;
7 years ago
}
public void setClazz(Class clazz) {
this.clazz = clazz;
}
public Boolean getNeedHead() {
return needHead;
}
public void setNeedHead(Boolean needHead) {
this.needHead = needHead;
}
public List<Handler> getHandler() {
return handler;
}
public void setHandler(List<Handler> handler) {
this.handler = handler;
}
@Override
public String toString() {
return "Table{" + "tableNo=" + tableNo + '}';
7 years ago
}
}