自定义工具类:导入工具类测试
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                自定义工具类:导入工具类测试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                工具類完成導入導出?
(1)導入數據
List<User> list = new ExcelImportUtil(User.class).readExcel(is, 1, 2);(2)導出數據?
@RequestMapping(value = "/export/{month}", method = RequestMethod.GET) public void export(@PathVariable(name = "month") String month) throws Exception {//1.構造數據List<EmployeeReportResult> list =userCompanyPersonalService.findByReport(companyId,month+"%");//2.加載模板流數據Resource resource = new ClassPathResource("excel-template/hr-demo.xlsx");FileInputStream fis = new FileInputStream(resource.getFile());new ExcelExportUtil(EmployeeReportResult.class,2,2).export(response,fis,list,"人事報表.xlsx"); } package com.learn.domain.employee.response;import com.learn.domain.employee.EmployeeResignation; import com.learn.domain.employee.UserCompanyPersonal; import com.learn.domain.poi.ExcelAttribute; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; import org.springframework.beans.BeanUtils;@Getter @Setter @NoArgsConstructor @ToString public class EmployeeReportResult {@ExcelAttribute(sort = 0)private String userId;@ExcelAttribute(sort = 1)private String username;private String departmentName;@ExcelAttribute(sort = 2)private String mobile;@ExcelAttribute(sort = 9)private String timeOfEntry;private String companyId;private String sex;/*** 出生日期*/private String dateOfBirth;/*** 最高學歷*/@ExcelAttribute(sort = 3)private String theHighestDegreeOfEducation;/*** 國家地區(qū)*/@ExcelAttribute(sort = 4)private String nationalArea;/*** 護照號*/@ExcelAttribute(sort = 5)private String passportNo;/*** 身份證號*/private String idNumber;/*** 身份證照片-正面*/private String idCardPhotoPositive;/*** 身份證照片-背面*/private String idCardPhotoBack;/*** 籍貫*/@ExcelAttribute(sort = 6)private String nativePlace;/*** 民族*/private String nation;/*** 英文名*/private String englishName;/*** 婚姻狀況*/private String maritalStatus;/*** 員工照片*/private String staffPhoto;/*** 生日*/@ExcelAttribute(sort = 7)private String birthday;/*** 屬相*/@ExcelAttribute(sort = 8)private String zodiac;/*** 年齡*/private String age;/*** 星座*/private String constellation;/*** 血型*/private String bloodType;/*** 戶籍所在地*/private String domicile;/*** 政治面貌*/private String politicalOutlook;/*** 入黨時間*/private String timeToJoinTheParty;/*** 存檔機構*/private String archivingOrganization;/*** 子女狀態(tài)*/private String stateOfChildren;/*** 子女有無商業(yè)保險*/private String doChildrenHaveCommercialInsurance;/*** 有無違法違紀行為*/private String isThereAnyViolationOfLawOrDiscipline;/*** 有無重大病史*/private String areThereAnyMajorMedicalHistories;/*** QQ*/private String qq;/*** 微信*/private String wechat;/*** 居住證城市*/private String residenceCardCity;/*** 居住證辦理日期*/private String dateOfResidencePermit;/*** 居住證截止日期*/private String residencePermitDeadline;/*** 現居住地*/private String placeOfResidence;/*** 通訊地址*/private String postalAddress;/*** 聯系手機*/private String contactTheMobilePhone;/*** 個人郵箱*/private String personalMailbox;/*** 緊急聯系人*/private String emergencyContact;/*** 緊急聯系電話*/private String emergencyContactNumber;/*** 社保電腦號*/private String socialSecurityComputerNumber;/*** 公積金賬號*/private String providentFundAccount;/*** 銀行卡號*/private String bankCardNumber;/*** 開戶行*/private String openingBank;/*** 學歷類型*/private String educationalType;/*** 畢業(yè)學校*/private String graduateSchool;/*** 入學時間*/private String enrolmentTime;/*** 畢業(yè)時間*/private String graduationTime;/*** 專業(yè)*/private String major;/*** 畢業(yè)證書*/private String graduationCertificate;/*** 學位證書*/private String certificateOfAcademicDegree;/*** 上家公司*/private String homeCompany;/*** 職稱*/private String title;/*** 簡歷*/private String resume;/*** 有無競業(yè)限制*/private String isThereAnyCompetitionRestriction;/*** 前公司離職證明*/private String proofOfDepartureOfFormerCompany;/*** 備注*/private String remarks;/*** 離職時間*/@ExcelAttribute(sort = 12)private String resignationTime;/*** 離職類型*/@ExcelAttribute(sort = 10)private String typeOfTurnover;/*** 申請離職原因*/@ExcelAttribute(sort = 11)private String reasonsForLeaving;public EmployeeReportResult(UserCompanyPersonal personal, EmployeeResignation resignation) {BeanUtils.copyProperties(personal,this);if(resignation != null) {BeanUtils.copyProperties(resignation,this);}} }?
總結
以上是生活随笔為你收集整理的自定义工具类:导入工具类测试的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: POI导出人事报表:代码实现
 - 下一篇: 百万数据报表:分析以及解决办法