parent
02ff516f0f
commit
f942b34d02
@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.excel.core.util;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel 工具类
|
||||||
|
*/
|
||||||
|
public class ExcelUtils {
|
||||||
|
|
||||||
|
public static void write(HttpServletResponse response, String filename, String sheetName,
|
||||||
|
Class<?> head, List<?> data) throws IOException {
|
||||||
|
// 设置 header 和 contentType
|
||||||
|
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
|
||||||
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||||
|
// 输出 Excel
|
||||||
|
EasyExcel.write(response.getOutputStream(), head)
|
||||||
|
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度
|
||||||
|
.sheet(sheetName).doWrite(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package cn.iocoder.dashboard.modules.system.controller.user.vo.user;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@ApiModel(value = "用户导出 Request VO", description = "参数和 SysUserPageReqVO 是一致的")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SysUserExportReqVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户账号", example = "yudao", notes = "模糊匹配")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "手机号码", example = "yudao", notes = "模糊匹配")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "展示状态", example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "开始时间", example = "2020-10-24")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private Date beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束时间", example = "2020-10-24")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "部门编号", example = "1024", notes = "同时筛选子部门")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue