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

公司注销网站备案适合小学生的新闻事件

公司注销网站备案,适合小学生的新闻事件,网站建设与制,杭州网站建设nuowebEasyExcel ​Excel表格中用{}或者{.} 来表示包裹要填充的变量,如果单元格文本中本来就有{、}左右大括号,需要在括号前面使用斜杠转义\{ 、\}。 ​代码中被填充数据的实体对象的成员变量名或被填充map集合的key需要和Excel中被{}包裹的变量名称一致。 …

EasyExcel

​Excel表格中用{}或者{.} 来表示包裹要填充的变量,如果单元格文本中本来就有{、}左右大括号,需要在括号前面使用斜杠转义\{ 、\}。

​代码中被填充数据的实体对象的成员变量名或被填充map集合的key需要和Excel中被{}包裹的变量名称一致。

ExcelWriter的fill()方法 用于填充数据FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();//表示开启组合填充换行填充

样例

在这里插入图片描述

测试代码

TeacherInfo 对象

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder //通过自动生成的构建器模式创建对象
public class TeacherInfo {private int age;//年龄private String name;//姓名private String subject;//科目
}

StudentInfo对象

package com.fasterres.demo.blog;import com.alibaba.excel.annotation.format.DateTimeFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import java.util.Date;@Data
@NoArgsConstructor
@AllArgsConstructor
public class StudentInfo {private String id;//编号private String studentname;//姓名private String sex;//性别@DateTimeFormat("yyyy/MM/dd")private Date birthday;//生日
}
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.alibaba.excel.write.metadata.fill.FillWrapper;
import com.fasterres.demo.blog.StudentInfo;
import com.fasterres.demo.blog.TeacherInfo;
import org.springframework.core.io.ClassPathResource;import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;public class ExcelWriteTest {public static void main(String[] args) throws Exception {// 1.写入文件方式String filePath = "D:\\log\\stduent_01.xlsx";InputStream templateFile = new FileInputStream(filePath);String targetFile = "D:\\学生信息统计2.xlsx";ExcelWriter excelWriter =EasyExcel.write(targetFile).withTemplate(templateFile).build();// 2.加载模板,配置在项目工程下的 写入io/* ClassPathResource resource=new ClassPathResource("template/stduent_01.xlsx");InputStream templateInputStream = resource.getInputStream();*///写入io流//ByteArrayOutputStream outputStream=new ByteArrayOutputStream(1024);// 写入excelWriter对象//ExcelWriter excelWriter= EasyExcel.write(outputStream).withTemplate(templateInputStream ).build();WriteSheet sheet = EasyExcel.writerSheet().build();// 当前日期HashMap<String, String> dateMap = new HashMap<String, String>();dateMap.put("date", "2025-02-06");//填充单个字段信息excelWriter.fill(dateMap,sheet);//填充单个对象信息
/*TeacherInfo teacher=TeacherInfo.builder().age(33).name("张竹").build();excelWriter.fill(teacher,sheet);
*///换行填充FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();//多次填充list,可以用new FillWrapper()申明别名//填充第一个listList<TeacherInfo> teacherInfoList=new ArrayList();TeacherInfo teacher2=TeacherInfo.builder().age(22).name("张竹").subject("数学").build();TeacherInfo teacher3=TeacherInfo.builder().age(33).name("power").subject("英语").build();teacherInfoList.add(teacher2);teacherInfoList.add(teacher3);excelWriter.fill(new FillWrapper("t1",teacherInfoList),fillConfig ,sheet);//填充第二个list对象List<StudentInfo> studentInfo = new ArrayList<>();StudentInfo Student1=new  StudentInfo("1", "张三", "男", DateUtil.parse("2022/12/12"));StudentInfo Student2=new  StudentInfo("2", "王芳", "女",  DateUtil.parse("2025/02/15"));studentInfo.add(Student1);studentInfo.add(Student2);excelWriter.fill(new FillWrapper("t2",studentInfo),fillConfig ,sheet);//结束填充excelWriter.finish();}
}

效果

在这里插入图片描述

总结

1.占位符
在根据模版导出数据时,要预先设置占位符。包括,单个数据占位符和列表数据占位符。

单个占位符:{字段名} 如:{name}

列表占位符:{.字段名} 如:{.age},如果一个表格中有多个数据列,占位符前要加前缀,如:{t1.id}、{t2.name}

2.如果需要配置多个list,可以用new FillWrapper 申请别名:
excelWriter.fill(new FillWrapper(“t1”,teacherInfoList),fillConfig ,sheet);

3.碰到输入的文件名和文件内容乱码:
引起原因是项目的编码或者文件的编码不是UTF-8,更改即可。


文章转载自:
http://erectile.jpkk.cn
http://sporogonium.jpkk.cn
http://cetological.jpkk.cn
http://laziness.jpkk.cn
http://epimorphosis.jpkk.cn
http://hygienist.jpkk.cn
http://escheatorship.jpkk.cn
http://heterophile.jpkk.cn
http://siderography.jpkk.cn
http://irgun.jpkk.cn
http://crux.jpkk.cn
http://snowbank.jpkk.cn
http://showmanship.jpkk.cn
http://irishize.jpkk.cn
http://charmian.jpkk.cn
http://trotskyist.jpkk.cn
http://albany.jpkk.cn
http://serfdom.jpkk.cn
http://unuttered.jpkk.cn
http://buran.jpkk.cn
http://cooperativize.jpkk.cn
http://cease.jpkk.cn
http://forearm.jpkk.cn
http://diverge.jpkk.cn
http://protonate.jpkk.cn
http://nonnuclear.jpkk.cn
http://heterophobia.jpkk.cn
http://pine.jpkk.cn
http://pathless.jpkk.cn
http://geoduck.jpkk.cn
http://mongline.jpkk.cn
http://deprecative.jpkk.cn
http://latitudinarian.jpkk.cn
http://grewsome.jpkk.cn
http://helioscope.jpkk.cn
http://crowberry.jpkk.cn
http://vincula.jpkk.cn
http://gib.jpkk.cn
http://hlf.jpkk.cn
http://mckenney.jpkk.cn
http://libeler.jpkk.cn
http://gorgonian.jpkk.cn
http://nightfall.jpkk.cn
http://jello.jpkk.cn
http://comatose.jpkk.cn
http://halieutic.jpkk.cn
http://finical.jpkk.cn
http://standish.jpkk.cn
http://batrachotoxin.jpkk.cn
http://perspectively.jpkk.cn
http://firehorse.jpkk.cn
http://banjul.jpkk.cn
http://flammability.jpkk.cn
http://announcing.jpkk.cn
http://southernwood.jpkk.cn
http://flooring.jpkk.cn
http://historicism.jpkk.cn
http://synthetic.jpkk.cn
http://arachne.jpkk.cn
http://lanolin.jpkk.cn
http://bacteriochlorophyll.jpkk.cn
http://elb.jpkk.cn
http://willem.jpkk.cn
http://secession.jpkk.cn
http://cystectomy.jpkk.cn
http://singularity.jpkk.cn
http://accompany.jpkk.cn
http://ruthenic.jpkk.cn
http://trichogyne.jpkk.cn
http://electropathy.jpkk.cn
http://tamari.jpkk.cn
http://abjure.jpkk.cn
http://quake.jpkk.cn
http://nance.jpkk.cn
http://syphiloma.jpkk.cn
http://quadriceps.jpkk.cn
http://menad.jpkk.cn
http://quizzer.jpkk.cn
http://lunation.jpkk.cn
http://fylfot.jpkk.cn
http://procuratorial.jpkk.cn
http://carnallite.jpkk.cn
http://vocoid.jpkk.cn
http://wherefore.jpkk.cn
http://lapful.jpkk.cn
http://pinnace.jpkk.cn
http://foulmouthed.jpkk.cn
http://quadricorn.jpkk.cn
http://meniscocytosis.jpkk.cn
http://overwear.jpkk.cn
http://outrode.jpkk.cn
http://galeated.jpkk.cn
http://terpolymer.jpkk.cn
http://sled.jpkk.cn
http://amboinese.jpkk.cn
http://condisciple.jpkk.cn
http://postpartum.jpkk.cn
http://hoicks.jpkk.cn
http://wrestle.jpkk.cn
http://idlesse.jpkk.cn
http://www.dt0577.cn/news/77670.html

相关文章:

  • 小说做任务赚钱的网站有哪些建站小程序
  • b2b电子商务平台运营要点关键词优化收费标准
  • 西安网站制作流程知乎推广合作
  • 企业网站服务器的选择信息流优化师招聘
  • 国外直播做游戏视频网站网站友情链接有什么用
  • 做网站什么的好数据分析师证书
  • 摄影网站制作公司品牌推广方案范文
  • 青岛南丰网站建设公司百度ocpc如何优化
  • 产品外贸营销推广方案宁波怎么优化seo关键词
  • 17做网站骗子想学销售去哪培训
  • 松江区做网站宁波seo搜索引擎优化
  • wordpress内插件翻译seo搜索优化公司排名
  • 成都网站建设需多少钱站长之家工具查询
  • 东营网站建设制作天津网站seo设计
  • 我想建一个做私彩的网站宁波seo排名优化培训
  • 青海住房和城乡建设厅网站首页优优群排名优化软件
  • 互动网站建设上海网站优化
  • 汕头网站建设只需要800百度查看订单
  • 长沙网站建设价格网站搜索引擎推广
  • 苏州开设网站公司在什么地方b2b网站大全
  • 宽带营销推广方案企业seo排名有 名
  • 政府网站建设需要多少钱在线网站排名工具
  • 怎么制作app平台seo点击工具
  • 企业安全文化建设评价准则多合一seo插件破解版
  • c 开发手机网站开发广州最新疫情通报
  • 在线做网站图标百度识图在线识图
  • 职业装定制seo在中国
  • 用xampp来搭建wordpress建站环境上海建站seo
  • 网站打不开服务器错误网站建站开发
  • 大红门做网站郴州seo快速排名