纠纷奇闻作文社交美文家庭
聚热点
家庭城市
爱好生活
创业男女
能力餐饮
美文职业
心理周易
母婴奇趣
两性技能
社交传统
新闻范文
工作个人
思考社会
作文职场
家居中考
兴趣安全
解密魅力
奇闻笑话
写作笔记
阅读企业
饮食时事
纠纷案例
初中历史
说说童话
乐趣治疗

java使用easypoi导出多表头文件

7月27日 吴梦筱投稿
  效果:
  导入依赖:dependencygroupIdcn。afterturngroupIdeasypoibaseartifactIdversion3。2。0versiondependencydependencygroupIdcn。afterturngroupIdeasypoiwebartifactIdversion3。2。0versiondependencydependencygroupIdcn。afterturngroupIdeasypoiannotationartifactIdversion3。2。0versiondependency
  创建Excel对应文件CostReductionStatiImprotVoDataEqualsAndHashCode(callSuperfalse)publicclassCostReductionStatiImprotVoimplementsSerializable{privatestaticfinallongserialVersionUID1L;年度Excel(isWrapfalse,name年度,orderNum1,width20,needMergetrue)privateS供应商编码Excel(isWrapfalse,name供应商编码,orderNum2,width23,needMergetrue)privateStringsuppC供应商名称Excel(isWrapfalse,name供应商名称,orderNum3,width30,needMergetrue)privateStringsuppN物料编码Excel(isWrapfalse,name物料编码,orderNum4,width25,needMergetrue)privateStringmasterC物料名称Excel(isWrapfalse,name物料名称,orderNum5,width30,needMergetrue)privateStringmasterN调价原因Excel(isWrapfalse,name调价原因,orderNum6,width30,needMergetrue)privateStringmodifyPriceR开始日期Excel(isWrapfalse,name开始日期,orderNum7,width30,needMergetrue)privateStringstartT单价差额Excel(isWrapfalse,name单价差额,orderNum8,width30,needMergetrue)privateStringunitPriceD一月ExcelCollection(name一月,orderNum9)privateListJanMonthlyV二月ExcelCollection(name二月,orderNum10)privateListFebMonthlyV三月ExcelCollection(name三月,orderNum11)privateListMarMonthlyV四月ExcelCollection(name四月,orderNum12)privateL五月ExcelCollection(name五月,orderNum13)privateListMayMonthlyV六月ExcelCollection(name六月,orderNum14)privateListJunMonthlyV七月ExcelCollection(name七月,orderNum15)privateListJulyMonthlyV八月ExcelCollection(name八月,orderNum16)privateL九月ExcelCollection(name九月,orderNum17)privateListSepMonthlyV十月ExcelCollection(name十月,orderNum18)privateListOctMonthlyV十一月ExcelCollection(name十一月,orderNum19)privateListNovMonthlyV十二月ExcelCollection(name十二月,orderNum20)privateListDecMonthlyV累计用量合计Excel(isWrapfalse,name累计用量合计,orderNum21,width30,needMergetrue)privateLongcumulativeUsS降本金额合计Excel(isWrapfalse,name降本金额合计,orderNum22,width30,needMergetrue)privateStringcostReductAmountS统计时间Excel(isWrapfalse,name统计时间,orderNum23,width30,needMergetrue)privateStringstatiT}说明:orderNum:排序,如果属性顺序和表格字段顺序不一致,可已设置顺序width:表格列宽needMerge:是否需要合并单元格ExcelCollection(name十二月,orderNum20)对应双层表头字段特别注意!!!!踩坑属性字段必须遵守驼峰命名发,首字母小写!!!!!!注意属性,Excel支持属性类型不多,我使用的都是基本常用属性,在serviceImpl类中再做在转换
  CostReductionStatiImprotVo类中,多层表头字段对应一个lislist里面的也需单独建VO
  例如:JanMonthlyVoDataEqualsAndHashCode(callSuperfalse)publicclassJanMonthlyVoimplementsSerializable{privatestaticfinallongserialVersionUID2L;一月累计用量Excel(isWrapfalse,name一月累计用量,orderNum1,width15)privateIntegercumulativeUsJ一月降本金额Excel(isWrapfalse,name一月降本金额,orderNum2,width15)privateStringcostReductAmountJ}
  Contorller层:导出多重表头paramresponsethrowsExceptionPostMapping(exportExcel)publicvoidexportExcel(HttpServletResponseresponse,RequestBodyPageParamVOparams)throwsException{buCostReductionStatiYWService。exportExcel(response,params);}
  ServiceImpl层:导出paramresponsethrowsExceptionOverridepublicvoidexportExcel(HttpServletResponseresponse,PageParamVOparamVO)throwsException{ListCostReductionStatiImprotVoimportInfoListgetAllCostReductionImportInfo(paramVO);response。setContentType(applicationvnd。openxmlformatsofficedocument。spreadsheetml。charsetutf8);test。xls是弹出下载对话框的文件名,不能为中文,中文请自行编码response。setHeader(ContentDisposition,filenamefile。xlsx);HashMapString,ObjectmapnewHashMap();WorkbookworkbookExcelExportUtil。exportExcel(newExportParams(),CostReductionStatiImprotVo。class,importInfoList);workbook。setSheetName(0,降本统计);ServletOutputStreamoutputStreamresponse。getOutputStream();workbook。write(outputStream);outputStream。flush();outputStream。close();workbook。close();}获取数据publicListCostReductionStatiImprotVogetAllCostReductionImportInfo(PageParamVOparamVO){ArrayListCostReductionStatiImprotVoImprotVoListnewArrayList();ListDataFilterfilterparamVO。getFilter();ListBuCostReductionStatiEntityentityListbuCostReductionStatiMapper。selectList(WrapperFilter。buildQueryWrapper(newQueryWrapper(),filter));SimpleDateFormatformatnewSimpleDateFormat(yyyyMMddHH:ss:mm);if(CollectionUtils。isNotEmpty(entityList)){for(BuCostReductionStatiEntityentity:entityList){JanMonthlyVojanMonthlyVonewJanMonthlyVo();FebMonthlyVofebMonthlyVonewFebMonthlyVo();MarMonthlyVomarMonthlyVonewMarMonthlyVo();AprMonthlyVoaprMonthlyVonewAprMonthlyVo();MayMonthlyVomayMonthlyVonewMayMonthlyVo();JunMonthlyVojunMonthlyVonewJunMonthlyVo();JulyMonthlyVojulyMonthlyVonewJulyMonthlyVo();AugMonthlyVoaugMonthlyVonewAugMonthlyVo();SepMonthlyVosepMonthlyVonewSepMonthlyVo();OctMonthlyVooctMonthlyVonewOctMonthlyVo();NovMonthlyVonovMonthlyVonewNovMonthlyVo();DecMonthlyVodecMonthlyVonewDecMonthlyVo();ArrayListJanMonthlyVojanMonthlyVosnewArrayList();ArrayListFebMonthlyVofebMonthlyVosnewArrayList();ArrayListMarMonthlyVomarMonthlyVosnewArrayList();ArrayListaprMonthlyVosnewArrayList();ArrayListMayMonthlyVomayMonthlyVosnewArrayList();ArrayListJunMonthlyVojunMonthlyVosnewArrayList();ArrayListJulyMonthlyVojulyMonthlyVosnewArrayList();ArrayListaugMonthlyVosnewArrayList();ArrayListSepMonthlyVosepMonthlyVosnewArrayList();ArrayListOctMonthlyVooctMonthlyVosnewArrayList();ArrayListNovMonthlyVonovMonthlyVosnewArrayList();ArrayListDecMonthlyVodecMonthlyVosnewArrayList();CostReductionStatiImprotVoimprotVonewCostReductionStatiImprotVo();improtVo。setYear(entity。getYear());improtVo。setMasterCode(entity。getMasterCode());improtVo。setMasterName(entity。getMasterName());improtVo。setSuppCode(entity。getSuppCode());improtVo。setSuppName(entity。getSuppName());switch(entity。getModifyPriceReson()){caseT02:improtVo。setModifyPriceReson(BuCostReductionStatiConstans。T02CH);caseT03:improtVo。setModifyPriceReson(BuCostReductionStatiConstans。T03CH);caseT04:improtVo。setModifyPriceReson(BuCostReductionStatiConstans。T04CH);caseT05:improtVo。setModifyPriceReson(BuCostReductionStatiConstans。T05CH);caseT06:improtVo。setModifyPriceReson(BuCostReductionStatiConstans。T06CH);}improtVo。setStartTime(format。format(entity。getStartTime()));improtVo。setUnitPriceDifference(entity。getUnitPriceDifference()null?null:entity。getUnitPriceDifference()。toString());improtVo。setCumulativeUsSum(entity。getCumulativeUsSum());improtVo。setCostReductAmountSum(entity。getCostReductAmountSum()null?null:entity。getCostReductAmountSum()。toString());improtVo。setStatiTime(format。format(entity。getStatiTime()));janMonthlyVo。setCumulativeUsJan(entity。getCumulativeUsJan());janMonthlyVo。setCostReductAmountJan(entity。getCostReductAmountJan()null?null:entity。getCostReductAmountJan()。toString());janMonthlyVos。add(janMonthlyVo);improtVo。setJanuary(janMonthlyVos);febMonthlyVo。setCumulativeUsFeb(entity。getCumulativeUsFeb());febMonthlyVo。setCostReductAmountFeb(entity。getCostReductAmountFeb()null?null:entity。getCostReductAmountFeb()。toString());febMonthlyVos。add(febMonthlyVo);improtVo。setFebruary(febMonthlyVos);marMonthlyVo。setCumulativeUsMar(entity。getCumulativeUsMar());marMonthlyVo。setCostReductAmountMar(entity。getCostReductAmountMar()null?null:entity。getCostReductAmountMar()。toString());marMonthlyVos。add(marMonthlyVo);improtVo。setMarch(marMonthlyVos);aprMonthlyVo。setCumulativeUsApr(entity。getCumulativeUsApr());aprMonthlyVo。setCostReductAmountApr(entity。getCostReductAmountApr()null?null:entity。getCostReductAmountApr()。toString());aprMonthlyVos。add(aprMonthlyVo);improtVo。setApril(aprMonthlyVos);mayMonthlyVo。setCumulativeUsMay(entity。getCumulativeUsMay());mayMonthlyVo。setCostReductAmountMay(entity。getCostReductAmountMay()null?null:entity。getCostReductAmountMay()。toString());mayMonthlyVos。add(mayMonthlyVo);improtVo。setMay(mayMonthlyVos);junMonthlyVo。setCumulativeUsJun(entity。getCumulativeUsJun());junMonthlyVo。setCostReductAmountJun(entity。getCostReductAmountJun()null?null:entity。getCostReductAmountJun()。toString());junMonthlyVos。add(junMonthlyVo);improtVo。setJune(junMonthlyVos);julyMonthlyVo。setCumulativeUsJul(entity。getCumulativeUsJul());julyMonthlyVo。setCostReductAmountJul(entity。getCostReductAmountJul()null?null:entity。getCostReductAmountJul()。toString());julyMonthlyVos。add(julyMonthlyVo);improtVo。setJuly(julyMonthlyVos);augMonthlyVo。setCumulativeUsAug(entity。getCumulativeUsAug());augMonthlyVo。setCostReductAmountAug(entity。getCostReductAmountAug()null?null:entity。getCostReductAmountAug()。toString());augMonthlyVos。add(augMonthlyVo);improtVo。setAugust(augMonthlyVos);sepMonthlyVo。setCumulativeUsSep(entity。getCumulativeUsSep());sepMonthlyVo。setCostReductAmountSep(entity。getCostReductAmountSep()null?null:entity。getCostReductAmountSep()。toString());sepMonthlyVos。add(sepMonthlyVo);improtVo。setSeptember(sepMonthlyVos);improtVo。getSeptember();octMonthlyVo。setCumulativeUsOct(entity。getCumulativeUsOct());octMonthlyVo。setCostReductAmountOct(entity。getCostReductAmountOct()null?null:entity。getCostReductAmountOct()。toString());octMonthlyVos。add(octMonthlyVo);improtVo。setOctober(octMonthlyVos);novMonthlyVo。setCumulativeUsNov(entity。getCumulativeUsNov());novMonthlyVo。setCostReductAmountNov(entity。getCostReductAmountNov()null?null:entity。getCostReductAmountNov()。toString());novMonthlyVos。add(novMonthlyVo);improtVo。setNovember(novMonthlyVos);decMonthlyVo。setCumulativeUsDec(entity。getCumulativeUsDec());decMonthlyVo。setCostReductAmountDec(entity。getCostReductAmountDec()null?null:entity。getCostReductAmountDec()。toString());decMonthlyVos。add(decMonthlyVo);improtVo。setDecember(decMonthlyVos);ImprotVoList。add(improtVo);}returnImprotVoL}}
  第一次写多表头导出,特意记录一下。
投诉 评论 转载

河北农村之茂林庄村今天去了一个村此就涿州的茂林庄村,从村里转了一圈还是让我觉得比以前变化挺大的。进村有一个牌楼,牌楼上写有茂林村四个字。牌楼旁还是有上防疫执勤的,外村人进村也是要登记得。……对话品胜赵国成,中国做硬件的企业需要沉下心来,需要数字化采访、撰文宇婷他一定要去做他喜欢的事情。赵国成提到无招对于智能硬件场景的观察、定义和前瞻,以及同时具备数字化的思维时,神采奕奕。这是一场由HHOGene举办的发布会……java使用easypoi导出多表头文件效果:导入依赖:dependencygroupIdcn。afterturngroupIdeasypoibaseartifactIdversion3。2。0versiond……一去三千里用脚丈量真实的大地每经记者:苏娜每经编辑:刘艳美图来源:摄图网501077344如何理解一段历史?如何认识一座城市?在无法随时随地说走就走的今天,尽管信息技术已经可以让我们足不……已经是上市三个月的机器,目前缺货中,粉丝加价600买14pr实话实说iPhone14Pro是这两年变化最小的iPhone,没有7到X的那种惊喜,没有11Pro到12Pro那种一眼能看出差别的提升,更没有12Pro到13Pro那种用了都说……人有千算,天则一算,这五条规矩不可违反!世间万物都在不停的运转,他们都有各自的规律,虽然有时看似杂乱无章,但仔细研究之后,你依然会发现,所有的事物都遵循着一个特定的规律在运行。事物和事物之间的关系,也就是作用力和反作……平凡的生活,不平凡的人生一生争渡,却平平凡凡。这是大多数人的真实写照。但我们要的就是在平凡的人生中去追寻不平凡。古往今来,不论平地与山尖,不论朝代兴与衰,生在这世界上,每一个人都为人类社会的进步……儿子的难言之隐我家孩子从小皮肤就属于黑的,没有遗传到我的白,虽然我在怀孕期间努力的吃苹果和喝牛奶,都没能干过他爹那边强大的基因黑就黑吧,男孩子嘛无所谓。俗话说得好男孩子黑显的壮实可是后……明日NBA欧文缺席,阿杜PK东契奇老詹PK新科60分先生唐斯北京时间3月17日,NBA常规赛继续进行,我们推荐两场比赛,7:30布鲁克林篮网队主场迎战达拉斯独行侠队;8点整洛杉矶湖人队客场挑战明尼苏达森林狼队。欧文无法出战主场比赛……孩子是早长还是晚长,骨龄说了算!哪些孩子需要重点监测骨龄?前两天遇到一个家长,骨龄评估出来比实际年龄大了2岁,家长还是坚持孩子是晚长,因为孩子爸爸也是晚长,遇到这样的家长,我有心无力,精力有限,我只能把更多的精力给那些观念正确的家长。……兔年大吉祝福动态表情图,吉祥问候语,先收藏新春已至,问候由心而起,祝福款款而来,新一年,新气象,愿朋友〔2023〕年生活美美满满,事业红红火火,财源滚滚而来,幸福永永远远!春节一年复一年,在外人儿何时还;日夜打拼……TVB仙气女神露玉背迎30岁,现实中家底丰厚,自己创业开两店本文编辑剧透社:伊文未经授权严禁转载,发现抄袭者将进行全网投诉TVB剧集《有种好男人》日前正在热播中,在剧中与李佳芯一同争夺马德钟的TVB新晋女神伍乐怡近年来备受力……
打油诗一首打工人笑对人生苦中有甜TVB回应香港小姐被指色情,曾志伟因比赛遭隔空喊话吴昕春日迟迟再出发暖心安慰众嘉宾网友被多面性格圈粉国产芯片崛起,美国芯片再度衰退,手机芯片市场由国产芯片主导游本昌52岁演济公,89岁演忘忧大师,他的人生比剧本精彩诗歌今夜,有雨敲窗吐血整理,这5个腾讯出品的黑科技网站,好用到超出你的想像!卫塞节四天连假普吉岛旅游收益料大增3年1622万!火箭又一位离队球员出炉,航天城首对三巨头正式2022年末换机,不可错过的4款12256GB机型,性价比超永恒岛之彩虹回忆超详细攻略宝石的获取一场比赛两队输球
YS厂复刻GP芝柏金桥系列99193陀飞轮腕表鉴赏热传聚热点 【歌词】一场梦歌手:杨静热文聚热点网 月经期女性吃点蒜可以吗国民党主席朱立伦6月访美之行效益受关注热博聚热点网 秋冬皮肤“干”到脱皮?林允阚清子各有妙招,正确涂抹面霜很重要 被工作单位限制了发展,要不要跳槽?OL必知6时尚养生招保鲜你的青春班级口号大全霸气十足朝鲜人的住房靠分配,家里装修怎么样?失恋后我与老师展开爱情拉锯战离婚冷静期正式实行了吗?雨里忆阳光岁月800字优秀作文

友情链接:中准网聚热点快百科快传网快生活快软网快好知文好找美丽时装彩妆资讯历史明星乐活安卓数码常识驾车健康苹果问答网络发型电视车载室内电影游戏科学音乐整形