ソースを参照

!18 满足业务需要,在导出Excel需要指定某些列隐藏。

Merge pull request !18 from 小H/master
4.1.3.A
jueyue 7年前
コミット
95ec362ccc
5個のファイルの変更46行の追加9行の削除
  1. +10
    -4
      easypoi-annotation/src/main/java/cn/afterturn/easypoi/excel/annotation/Excel.java
  2. +15
    -3
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java
  3. +1
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportService.java
  4. +19
    -2
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java
  5. +1
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java

+ 10
- 4
easypoi-annotation/src/main/java/cn/afterturn/easypoi/excel/annotation/Excel.java ファイルの表示

@@ -1,6 +1,6 @@
/**
* Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -115,7 +115,7 @@ public @interface Excel {
/**
* 导入路径,如果是图片可以填写,默认是upload/className/ IconEntity这个类对应的就是upload/Icon/
*
*
*/
public String savePath() default "upload";
@@ -136,13 +136,13 @@ public @interface Excel {
* @return
*/
public boolean isStatistics() default false;
/**
* 这个是不是超链接,如果是需要实现接口返回对象
* @return
*/
public boolean isHyperlink() default false;
/**
* 导入时会校验这个字段,看看这个字段是不是导入的Excel中有,如果没有说明是错误的Excel
* 本意是想用true的,想想还是false比较好
@@ -156,4 +156,10 @@ public @interface Excel {
* @return
*/
public int fixedIndex() default -1;
/**
* 是否需要隐藏该列
* @return
*/
public boolean isColumnHidden() default false;
}

+ 15
- 3
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/entity/params/ExcelExportEntity.java ファイルの表示

@@ -1,6 +1,6 @@
/**
* Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -19,7 +19,7 @@ import java.util.List;
/**
* excel 导出工具类,对cell类型做映射
*
*
* @author JueYue
* @version 1.0 2013年8月24日
*/
@@ -58,7 +58,7 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc
*/
private boolean mergeVertical;
/**
* 合并依赖
* 合并依赖`
*/
private int[] mergeRely;
/**
@@ -71,6 +71,18 @@ public class ExcelExportEntity extends ExcelBaseEntity implements Comparable<Exc
private boolean isStatistics;
private String numFormat;
/**
* 是否隐藏列
*/
private boolean isColumnHidden;
public boolean isColumnHidden() {
return isColumnHidden;
}
public void setColumnHidden(boolean columnHidden) {
isColumnHidden = columnHidden;
}
private List<ExcelExportEntity> list;


+ 1
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/ExcelExportService.java ファイルの表示

@@ -167,6 +167,7 @@ public class ExcelExportService extends BaseExportService {
? createHeaderAndTitle(entity, sheet, workbook, excelParams) : 0;
int titleHeight = index;
setCellWith(excelParams, sheet);
setColumnHidden(excelParams,sheet);
short rowHeight = entity.getHeight() > 0 ? entity.getHeight() : getRowHeight(excelParams);
setCurrentIndex(1);
Iterator<?> its = dataSet.iterator();


+ 19
- 2
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/BaseExportService.java ファイルの表示

@@ -114,8 +114,8 @@ public abstract class BaseExportService extends ExportCommonService {
entity);
if (entity.isHyperlink()) {
row.getCell(cellNum - 1).setHyperlink(dataHanlder.getHyperlink(
row.getSheet().getWorkbook().getCreationHelper(), t,
entity.getName(), value));
row.getSheet().getWorkbook().getCreationHelper(), t,
entity.getName(), value));
}
} else {
createImageCell(patriarch, entity, row, cellNum++,
@@ -390,6 +390,23 @@ public abstract class BaseExportService extends ExportCommonService {
}
}


public void setColumnHidden(List<ExcelExportEntity> excelParams, Sheet sheet){
int index = 0;
for (int i = 0; i < excelParams.size(); i++) {
if (excelParams.get(i).getList() != null) {
List<ExcelExportEntity> list = excelParams.get(i).getList();
for (int j = 0; j < list.size(); j++) {
sheet.setColumnHidden(index,list.get(i).isColumnHidden());
index++;
}
} else {
sheet.setColumnHidden(index,excelParams.get(i).isColumnHidden());;
index++;
}
}
}

public void setCurrentIndex(int currentIndex) {
this.currentIndex = currentIndex;
}


+ 1
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/base/ExportCommonService.java ファイルの表示

@@ -242,6 +242,7 @@ public class ExportCommonService {
excelEntity.setHyperlink(excel.isHyperlink());
excelEntity.setMethod(PoiReflectorUtil.fromCache(pojoClass).getGetMethod(field.getName()));
excelEntity.setNumFormat(excel.numFormat());
excelEntity.setColumnHidden(excel.isColumnHidden());
if (excelGroup != null) {
excelEntity.setGroupName(PoiPublicUtil.getValueByTargetId(excelGroup.name(), targetId, null));
} else {


読み込み中…
キャンセル
保存