@@ -32,7 +32,7 @@ public @interface Excel { | |||||
/** | /** | ||||
* 导出时在excel中每个列的高度 单位为字符,一个汉字=2个字符 | * 导出时在excel中每个列的高度 单位为字符,一个汉字=2个字符 | ||||
*/ | */ | ||||
public int height() default 10; | |||||
public double height() default 10; | |||||
/** | /** | ||||
* 导出类型 1 从file读取 2 是从数据库中读取 默认是文件 同样导入也是一样的 | * 导出类型 1 从file读取 2 是从数据库中读取 默认是文件 同样导入也是一样的 | ||||
@@ -100,7 +100,7 @@ public @interface Excel { | |||||
* 导出时在excel中每个列的宽 单位为字符,一个汉字=2个字符 如 以列名列内容中较合适的长度 例如姓名列6 【姓名一般三个字】 | * 导出时在excel中每个列的宽 单位为字符,一个汉字=2个字符 如 以列名列内容中较合适的长度 例如姓名列6 【姓名一般三个字】 | ||||
* 性别列4【男女占1,但是列标题两个汉字】 限制1-255 | * 性别列4【男女占1,但是列标题两个汉字】 限制1-255 | ||||
*/ | */ | ||||
public int width() default 10; | |||||
public double width() default 10; | |||||
/** | /** | ||||
* 是否自动统计数据,如果是统计,true的话在最后追加一行统计,把所有数据都和 | * 是否自动统计数据,如果是统计,true的话在最后追加一行统计,把所有数据都和 | ||||
@@ -15,9 +15,9 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc | |||||
*/ | */ | ||||
private Object key; | private Object key; | ||||
private int width = 10; | |||||
private double width = 10; | |||||
private int height = 10; | |||||
private double height = 10; | |||||
/** | /** | ||||
* 图片的类型,1是文件,2是数据库 | * 图片的类型,1是文件,2是数据库 | ||||
@@ -80,7 +80,7 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc | |||||
return exportImageType; | return exportImageType; | ||||
} | } | ||||
public int getHeight() { | |||||
public double getHeight() { | |||||
return height; | return height; | ||||
} | } | ||||
@@ -100,7 +100,7 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc | |||||
return orderNum; | return orderNum; | ||||
} | } | ||||
public int getWidth() { | |||||
public double getWidth() { | |||||
return width; | return width; | ||||
} | } | ||||
@@ -120,7 +120,7 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc | |||||
this.exportImageType = exportImageType; | this.exportImageType = exportImageType; | ||||
} | } | ||||
public void setHeight(int height) { | |||||
public void setHeight(double height) { | |||||
this.height = height; | this.height = height; | ||||
} | } | ||||
@@ -148,7 +148,7 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc | |||||
this.orderNum = orderNum; | this.orderNum = orderNum; | ||||
} | } | ||||
public void setWidth(int width) { | |||||
public void setWidth(double width) { | |||||
this.width = width; | this.width = width; | ||||
} | } | ||||
@@ -478,11 +478,11 @@ public abstract class ExcelExportBase extends ExportBase { | |||||
if (excelParams.get(i).getList() != null) { | if (excelParams.get(i).getList() != null) { | ||||
List<ExcelExportEntity> list = excelParams.get(i).getList(); | List<ExcelExportEntity> list = excelParams.get(i).getList(); | ||||
for (int j = 0; j < list.size(); j++) { | for (int j = 0; j < list.size(); j++) { | ||||
sheet.setColumnWidth(index, 256 * list.get(j).getWidth()); | |||||
sheet.setColumnWidth(index, (int) (256 * list.get(j).getWidth())); | |||||
index++; | index++; | ||||
} | } | ||||
} else { | } else { | ||||
sheet.setColumnWidth(index, 256 * excelParams.get(i).getWidth()); | |||||
sheet.setColumnWidth(index, (int) (256 * excelParams.get(i).getWidth())); | |||||
index++; | index++; | ||||
} | } | ||||
} | } | ||||
@@ -271,7 +271,7 @@ public class ExportBase { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public short getRowHeight(List<ExcelExportEntity> excelParams) { | public short getRowHeight(List<ExcelExportEntity> excelParams) { | ||||
int maxHeight = 0; | |||||
double maxHeight = 0; | |||||
for (int i = 0; i < excelParams.size(); i++) { | for (int i = 0; i < excelParams.size(); i++) { | ||||
maxHeight = maxHeight > excelParams.get(i).getHeight() ? maxHeight : excelParams.get(i) | maxHeight = maxHeight > excelParams.get(i).getHeight() ? maxHeight : excelParams.get(i) | ||||
.getHeight(); | .getHeight(); | ||||
@@ -81,10 +81,10 @@ public final class ExcelExportOfTemplateUtil extends ExcelExportBase { | |||||
.newInstance(workbook)); | .newInstance(workbook)); | ||||
// 获取实体对象的导出数据 | // 获取实体对象的导出数据 | ||||
List<ExcelExportEntity> excelParams = new ArrayList<ExcelExportEntity>(); | List<ExcelExportEntity> excelParams = new ArrayList<ExcelExportEntity>(); | ||||
getAllExcelField(null, targetId, fileds, excelParams, pojoClass, null); | |||||
if (excelParams.size() == 0) { | if (excelParams.size() == 0) { | ||||
return; | return; | ||||
} | } | ||||
getAllExcelField(null, targetId, fileds, excelParams, pojoClass, null); | |||||
// 根据表头进行筛选排序 | // 根据表头进行筛选排序 | ||||
sortAndFilterExportField(excelParams, titlemap); | sortAndFilterExportField(excelParams, titlemap); | ||||
short rowHeight = getRowHeight(excelParams); | short rowHeight = getRowHeight(excelParams); | ||||