<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
@SneakyThrows
@GetMapping("/exportInputAnnualSurvey")
@Operation(summary = "导出年检费用模板")
public void exportInputAnnualSurvey(HttpServletResponse response) {
List<InputAnnualSurveyVo> list = new ArrayList<>();
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding(Charsets.UTF_8.name());
String fileName = URLEncoder.encode("年检费用", Charsets.UTF_8.name());
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xls");
EasyExcel.write(response.getOutputStream(), InputAnnualSurveyVo.class).sheet("年检费用表").doWrite(list);
}
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.handler.inter.IExcelDataModel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
@ExcelIgnoreUnannotated
public class InputAnnualSurveyVo implements IExcelDataModel, IExcelModel {
@Excel(name = "车牌号码", width = 10)
@ColumnWidth(15)
@ExcelProperty("车牌号码")
private String hostNo;
@Excel(name = "供应商名称", width = 10)
@ColumnWidth(15)
@ExcelProperty("供应商名称")
private String providerName;
@Excel(name = "本次年检日期", format = "yyyy-MM-dd HH:mm:ss", width = 10)
@ColumnWidth(15)
@ExcelProperty("本次年检日期")
private LocalDateTime surveyDate;
@Excel(name = "下次年检时间", format = "yyyy-MM-dd HH:mm:ss", width = 10)
@ColumnWidth(15)
@ExcelProperty("下次年检时间")
private LocalDateTime nextInspectionDate;
@Excel(name = "检验有效期截止", format = "yyyy-MM-dd HH:mm:ss", width = 10)
@ColumnWidth(15)
@ExcelProperty("检验有效期截止")
private LocalDateTime efficaciousDate;
@Excel(name = "年检费用", width = 10)
@ColumnWidth(15)
@ExcelProperty("年检费用")
private Double surveyCost;
@Excel(name = "合计", width = 10)
@ColumnWidth(15)
@ExcelProperty("合计")
private Double costSum;
@Excel(name = "经办人", width = 10)
@ColumnWidth(15)
@ExcelProperty("经办人")
private String operate;
@Column(comment = "备注")
@ColumnWidth(15)
@ExcelProperty("备注")
private String remark;
private Integer rowNum;
private String errorMsg;
}