Commit 850b489b authored by yanzg's avatar yanzg

导出Excel边框

parent 6590f3cf
package com.yanzuoguang.excel;
import io.swagger.annotations.ApiModelProperty;
/**
* 单元格
*
* @author 颜佐光
*/
public class ExcelDefineCell {
/**
* 横合并
*/
@ApiModelProperty(notes = "横合并")
private short widthSize;
/**
* 竖合并
*/
@ApiModelProperty(notes = "竖合并")
private short heightSize;
/**
* 对其
*/
@ApiModelProperty(notes = "左右对其:0-居中,1-左对其,2-右对齐")
private int alignment;
/**
* 对其
*/
@ApiModelProperty(notes = "上下对其:0-居中,1-上对其,2-下对齐")
private int verticalAlignment;
/**
* 文字内容
*/
@ApiModelProperty(notes = "文字内容")
private String value;
/**
* 公式,如:SUM(C2:C3),或者SUM(columnName),columnName=数据列名称,公式优先
*/
@ApiModelProperty(notes = " 公式,如:SUM(C2:C3),或者SUM(columnName),columnName=数据列名称,公式优先.不能SUM(columnA/columnB)")
private String formula;
public short getWidthSize() {
return widthSize;
}
public void setWidthSize(short widthSize) {
this.widthSize = widthSize;
}
public short getHeightSize() {
return heightSize;
}
public void setHeightSize(short heightSize) {
this.heightSize = heightSize;
}
public int getAlignment() {
return alignment;
}
public void setAlignment(int alignment) {
this.alignment = alignment;
}
public int getVerticalAlignment() {
return verticalAlignment;
}
public void setVerticalAlignment(int verticalAlignment) {
this.verticalAlignment = verticalAlignment;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
}
package com.yanzuoguang.excel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
/**
* 单元格
*
* @author 颜佐光
*/
public class ExcelDefineRow {
/**
* 高度
*/
@ApiModelProperty(notes = "高度")
private short height;
/**
* 单元格
*/
@ApiModelProperty(notes = "单元格")
private List<ExcelDefineCell> cells = new ArrayList<>();
public short getHeight() {
return height;
}
public void setHeight(short height) {
this.height = height;
}
public List<ExcelDefineCell> getCells() {
return cells;
}
public void setCells(List<ExcelDefineCell> cells) {
this.cells = cells;
}
}
......@@ -7,7 +7,7 @@ import com.yanzuoguang.util.base.ObjectHelper;
* 行数据默认处理
* @author 颜佐光
*/
public class ExcelRowDefault implements ExcelRow<Object> {
public class ExcelRowDefault<T> implements ExcelRow<T> {
/**
* 获取行里面的某列数据
......@@ -17,18 +17,7 @@ public class ExcelRowDefault implements ExcelRow<Object> {
* @return
*/
@Override
public String get(Object row, String field) {
public String get(T row, String field) {
return ObjectHelper.getString(row, field);
}
private static final ExcelRowDefault my = new ExcelRowDefault();
/**
* 获取默认实例
*
* @return
*/
public static ExcelRowDefault getInstance() {
return my;
}
}
......@@ -2,6 +2,7 @@ package com.yanzuoguang.excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.poi.ss.usermodel.CellStyle;
/**
* 列设置
......@@ -18,7 +19,7 @@ public class ExportColumn {
private String title;
/**
* 数据单元格
* 数据列名称
*/
@ApiModelProperty(notes = "数据列名称")
private String name;
......@@ -28,18 +29,25 @@ public class ExportColumn {
*/
@ApiModelProperty(notes = "数据是否合并")
private boolean merger;
/**
* 合并組
*/
@ApiModelProperty(notes = "合并組")
private String megerGroup;
/**
* 宽度
*/
@ApiModelProperty(notes = "宽度")
private short width;
/**
* 对其
*/
@ApiModelProperty(notes = "左右对其:0-居中,1-左对其,2-右对齐")
private int alignment;
/**
* 对其
*/
@ApiModelProperty(notes = "上下对其:0-居中,1-上对其,2-下对齐")
private int verticalAlignment;
ExcelMergerData groupData = new ExcelMergerData();
CellStyle cellStyle;
public ExportColumn() {
}
......@@ -55,11 +63,10 @@ public class ExportColumn {
this.width = width;
}
public ExportColumn(String title, String name, boolean merger, String megerGroup, short width) {
public ExportColumn(String title, String name, boolean merger, short width) {
this.title = title;
this.name = name;
this.merger = merger;
this.megerGroup = megerGroup;
this.width = width;
}
......@@ -87,14 +94,6 @@ public class ExportColumn {
this.merger = merger;
}
public String getMegerGroup() {
return megerGroup;
}
public void setMegerGroup(String megerGroup) {
this.megerGroup = megerGroup;
}
public short getWidth() {
if (this.width < 1) {
return ExportData.COLUMN_WIDTH;
......@@ -105,4 +104,20 @@ public class ExportColumn {
public void setWidth(short width) {
this.width = width;
}
public int getAlignment() {
return alignment;
}
public void setAlignment(int alignment) {
this.alignment = alignment;
}
public int getVerticalAlignment() {
return verticalAlignment;
}
public void setVerticalAlignment(int verticalAlignment) {
this.verticalAlignment = verticalAlignment;
}
}
......@@ -97,11 +97,21 @@ public class ExportData {
@ApiModelProperty(notes = "自动换行")
private boolean line;
/**
* 数据开始自定义行
*/
@ApiModelProperty(notes = "数据开始自定义行")
private List<ExcelDefineRow> startRows = new ArrayList<>();
/**
* 包含列
*/
@ApiModelProperty(notes = "包含列")
private List<ExportColumn> columns = new ArrayList<>();
/**
* 数据结束自定义行
*/
@ApiModelProperty(notes = "数据结束自定义行")
private List<ExcelDefineRow> endRows = new ArrayList<>();
public String getServerPath() {
return serverPath;
......@@ -195,6 +205,14 @@ public class ExportData {
this.line = line;
}
public List<ExcelDefineRow> getStartRows() {
return startRows;
}
public void setStartRows(List<ExcelDefineRow> startRows) {
this.startRows = startRows;
}
public List<ExportColumn> getColumns() {
return columns;
}
......@@ -202,4 +220,12 @@ public class ExportData {
public void setColumns(List<ExportColumn> columns) {
this.columns = columns;
}
public List<ExcelDefineRow> getEndRows() {
return endRows;
}
public void setEndRows(List<ExcelDefineRow> endRows) {
this.endRows = endRows;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment