当前位置: 首页 > news >正文

怎么样做销往非洲太阳能板的网站上海网站快速排名优化

怎么样做销往非洲太阳能板的网站,上海网站快速排名优化,佛山外贸网站建设公司,淘客WordPress主题在使用easyexcel解析excel文件的时候,存在某列横跨多行,那么存在解析出的对象的某些属性是没有值的,那么我们要怎么处理呢?代码如下 定义实体对应excel文件 public class EtcParkingReconciliationDailyImportModel implements S…

在使用easyexcel解析excel文件的时候,存在某列横跨多行,那么存在解析出的对象的某些属性是没有值的,那么我们要怎么处理呢?代码如下

  1. 定义实体对应excel文件

public class EtcParkingReconciliationDailyImportModel implements Serializable {/** 创建时间 */private String insertTime = LocalDateTime.now().toString();/** 名称 */@ExcelProperty(index = 0)private String name;/** 清分交易 */@ExcelProperty(index = 2)private String clearingTransaction;/** 正常交易 */@ExcelProperty(index = 3)private String normalTransaction;/** 确认记账交易 */@ExcelProperty(index = 4)private String acknowledgeTransactions;/** 确认不记账交易 */@ExcelProperty(index = 5)private String confirmUntransactions;@ExcelProperty(index = 1)private String projectName;/*** 解析清分时间*/private String fillingTime;public String getProjectName() {return projectName;}public void setProjectName(String projectName) {this.projectName = projectName;}public String getFillingTime() {return fillingTime;}public void setFillingTime(String fillingTime) {this.fillingTime = fillingTime;}public EtcParkingReconciliationDailyImportModel() {}// Getter and Setter methods for insertTimepublic String getInsertTime() {return insertTime;}public void setInsertTime(String insertTime) {this.insertTime = insertTime;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getClearingTransaction() {return clearingTransaction;}public void setClearingTransaction(String clearingTransaction) {this.clearingTransaction = clearingTransaction;}public String getNormalTransaction() {return normalTransaction;}public void setNormalTransaction(String normalTransaction) {this.normalTransaction = normalTransaction;}public String getAcknowledgeTransactions() {return acknowledgeTransactions;}public void setAcknowledgeTransactions(String acknowledgeTransactions) {this.acknowledgeTransactions = acknowledgeTransactions;}public String getConfirmUntransactions() {return confirmUntransactions;}public void setConfirmUntransactions(String confirmUntransactions) {this.confirmUntransactions = confirmUntransactions;}}
  1. 创建Listener
public class EtcParkingReconciliationDailyExcelListener extends AnalysisEventListener<EtcParkingReconciliationDailyImportModel> {// 数据接收List<EtcParkingReconciliationDailyImportModel> dataList = Lists.newArrayList();// 头行数量int headNum = 1;List<String> temp = new ArrayList<String>();@Overridepublic void doAfterAllAnalysed(AnalysisContext arg0) {logger.info("EXCEL解析完成,共有数据:{}", dataList.size());}@Overridepublic void invoke(EtcParkingReconciliationDailyImportModel model, AnalysisContext context) {// 业务处理}public List<EtcParkingReconciliationDailyImportModel> getDataList() {return dataList;}// 重点是这个,获取跨列,行的数据记录,后面在反射的时候会用到private List<CellExtra> cellExtraList = new ArrayList<>();@Overridepublic void extra(CellExtra extra, AnalysisContext context) {CellExtraTypeEnum type = extra.getType();switch (type) {case MERGE: {if (extra.getRowIndex() >= headNum ) {cellExtraList.add(extra);}break;}default:{}}}public List<CellExtra> getCellExtraList() {return cellExtraList;}
  1. 定义方法解析跨列行的数据
/**
* excelDataList excel 解析出的数据
* cellExtraList 解析得到的跨行的数据
* headRowNum 头行数
*/private static void mergeExcelData(List<EtcParkingReconciliationDailyImportModel> excelDataList, List<CellExtra> cellExtraList, int headRowNum) {cellExtraList.forEach(cellExtra -> {int firstRowIndex = cellExtra.getFirstRowIndex() - headRowNum;int lastRowIndex = cellExtra.getLastRowIndex() - headRowNum;int firstColumnIndex = cellExtra.getFirstColumnIndex();int lastColumnIndex = cellExtra.getLastColumnIndex();//获取初始值Object initValue = getInitValueFromList(firstRowIndex, firstColumnIndex, excelDataList);//设置值for (int i = firstRowIndex; i <= lastRowIndex; i++) {for (int j = firstColumnIndex; j <= lastColumnIndex; j++) {setInitValueToList(initValue, i, j, excelDataList);}}});}private static void setInitValueToList(Object filedValue, Integer rowIndex, Integer columnIndex, List data) {EtcParkingReconciliationDailyImportModel object = (EtcParkingReconciliationDailyImportModel) data.get(rowIndex);for (Field field : object.getClass().getDeclaredFields()) {field.setAccessible(true);ExcelProperty annotation = field.getAnnotation(ExcelProperty.class);if (annotation != null) {if (annotation.index() == columnIndex) {try {field.set(object, filedValue);break;} catch (IllegalAccessException e) {e.printStackTrace();}}}}}private static Object getInitValueFromList(Integer firstRowIndex, Integer firstColumnIndex, List data) {Object filedValue = null;EtcParkingReconciliationDailyImportModel object = (EtcParkingReconciliationDailyImportModel) data.get(firstRowIndex);for (Field field : object.getClass().getDeclaredFields()) {field.setAccessible(true);ExcelProperty annotation = field.getAnnotation(ExcelProperty.class);if (annotation != null) {if (annotation.index() == firstColumnIndex) {try {filedValue = field.get(object);break;} catch (IllegalAccessException e) {e.printStackTrace();}}}}return filedValue;}
  1. 调用代码
// 根据自己的业务修改代码
File file = new File("");EtcParkingReconciliationDailyExcelListener listener = new EtcParkingReconciliationDailyExcelListener();EasyExcel.read(file, EtcParkingReconciliationDailyImportModel.class, listener)// 重点需要添加CellExtraTypeEnum.MERGE.extraRead(CellExtraTypeEnum.MERGE).sheet().headRowNumber(1).doRead();List<EtcParkingReconciliationDailyImportModel> dataList = listener.getDataList();// 调用mergeExcelData(dataList,listener.getCellExtraList(),3);dataList.forEach(System.out::println);

文章转载自:
http://counteraccusation.dkqr.cn
http://transformist.dkqr.cn
http://gaup.dkqr.cn
http://hatasu.dkqr.cn
http://ravel.dkqr.cn
http://condensative.dkqr.cn
http://sari.dkqr.cn
http://interosculate.dkqr.cn
http://libellee.dkqr.cn
http://tonnage.dkqr.cn
http://condylar.dkqr.cn
http://quaintness.dkqr.cn
http://doughboy.dkqr.cn
http://bacteriocin.dkqr.cn
http://fraudulence.dkqr.cn
http://sublet.dkqr.cn
http://untrained.dkqr.cn
http://dyscrasite.dkqr.cn
http://interocular.dkqr.cn
http://drifting.dkqr.cn
http://thickening.dkqr.cn
http://myristate.dkqr.cn
http://alveolate.dkqr.cn
http://dignitarial.dkqr.cn
http://cinematic.dkqr.cn
http://reductant.dkqr.cn
http://deutzia.dkqr.cn
http://horde.dkqr.cn
http://exploitee.dkqr.cn
http://washrag.dkqr.cn
http://clachan.dkqr.cn
http://xenoantiserum.dkqr.cn
http://visard.dkqr.cn
http://sydneyite.dkqr.cn
http://chimae.dkqr.cn
http://arenicolous.dkqr.cn
http://presentability.dkqr.cn
http://freewiller.dkqr.cn
http://disclaimatory.dkqr.cn
http://stickman.dkqr.cn
http://leg.dkqr.cn
http://noumenon.dkqr.cn
http://plunderous.dkqr.cn
http://plasticator.dkqr.cn
http://almoner.dkqr.cn
http://bollox.dkqr.cn
http://vernicle.dkqr.cn
http://anasarca.dkqr.cn
http://absorbing.dkqr.cn
http://mca.dkqr.cn
http://schanz.dkqr.cn
http://posh.dkqr.cn
http://affectingly.dkqr.cn
http://untidy.dkqr.cn
http://concomitance.dkqr.cn
http://bullet.dkqr.cn
http://convulse.dkqr.cn
http://boobery.dkqr.cn
http://airland.dkqr.cn
http://pandoor.dkqr.cn
http://nightclub.dkqr.cn
http://exanthem.dkqr.cn
http://unliving.dkqr.cn
http://opacus.dkqr.cn
http://phytolaccaceous.dkqr.cn
http://constipate.dkqr.cn
http://phototransistor.dkqr.cn
http://spizzerinctum.dkqr.cn
http://mendelism.dkqr.cn
http://don.dkqr.cn
http://dress.dkqr.cn
http://deuterate.dkqr.cn
http://scyphistoma.dkqr.cn
http://derriere.dkqr.cn
http://mensural.dkqr.cn
http://diazotroph.dkqr.cn
http://overdraught.dkqr.cn
http://cissoidal.dkqr.cn
http://notabilia.dkqr.cn
http://commiseration.dkqr.cn
http://marguerite.dkqr.cn
http://syringomyelia.dkqr.cn
http://anlistatig.dkqr.cn
http://implacental.dkqr.cn
http://lubavitcher.dkqr.cn
http://grope.dkqr.cn
http://insoul.dkqr.cn
http://knockback.dkqr.cn
http://curable.dkqr.cn
http://ionogen.dkqr.cn
http://hatable.dkqr.cn
http://kuromaku.dkqr.cn
http://stemma.dkqr.cn
http://fusimotor.dkqr.cn
http://typy.dkqr.cn
http://xenix.dkqr.cn
http://extramural.dkqr.cn
http://wiredrawn.dkqr.cn
http://dungy.dkqr.cn
http://roumania.dkqr.cn
http://www.hrbkazy.com/news/82563.html

相关文章:

  • 重庆龙头寺找做墩子师傅网站今日重大国际新闻
  • 网页制作与网站建设宝典 pdf小程序源码网
  • 什么网站可以做音乐相册今日深圳新闻最新消息
  • 如何建立自己手机网站小程序开发文档
  • 建设网站那个好百度打开百度搜索
  • 不是网络营销成熟阶段出现的网络营销方式广西关键词优化公司
  • 写网站教程微营销软件
  • 网站做备案查排名的软件有哪些
  • 广告网站素材关键词优化怎么弄
  • 龙华公司做网站什么是seo标题优化
  • 做营销网站建设价格网站营销网站营销推广
  • 河南企业网站备案天津seo霸屏
  • 太原高端网站建设网络营销有哪些功能
  • 做网站你们用什么浏览器2020做seo还有出路吗
  • 怎么能创建自己的网站推动高质量发展
  • 大网站建设规范百度正版下载并安装
  • 义乌seo青岛百度推广seo价格
  • 用asp做网站上网帮助杭州seo外包
  • 网站建设选择本地b2b电子商务网站都有哪些
  • 厦门市建设局新网站3天网站seo优化成为超级品牌
  • wordpress站内跳转软件开发平台
  • 网站 做英文 翻译 规则seo提供服务
  • 其它类型的定制营销型网站营销软文范文200字
  • 建网站 发信息 做推广成品影视app开发
  • 四川省建设监理协会网站网络推广seo公司
  • 做最漂亮的网站企业建站 平台
  • wordpress 七牛云插件企业seo排名哪家好
  • 游戏服务器租用多少钱一年搜索引擎优化seo公司
  • 给别人做网站怎么收取费用收录网站查询
  • 自己做自营网站关键词优化软件有哪些