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

律师做几个网站做php网站用什么软件开发

律师做几个网站,做php网站用什么软件开发,论坛网站建设视频,wordpress paypal转账使用 EasyExcel 快速进行表格导入导出操作 在日常工作中#xff0c;表格的导入和导出是常见的需求。针对这种情况#xff0c;EasyExcel 提供了便捷的解决方案#xff0c;可以快速地实现 Excel 表格的导入和导出操作。本文将介绍如何使用 EasyExcel 进行表格导出#xff0c…使用 EasyExcel 快速进行表格导入导出操作 在日常工作中表格的导入和导出是常见的需求。针对这种情况EasyExcel 提供了便捷的解决方案可以快速地实现 Excel 表格的导入和导出操作。本文将介绍如何使用 EasyExcel 进行表格导出以及如何利用 EasyExcel 的特性来简化这一过程。 1. 添加 EasyExcel 依赖 首先需要在你的项目中添加 EasyExcel 的依赖。你可以通过 Maven 或 Gradle 将 EasyExcel 引入到项目中。以下是 Maven 依赖的示例 dependency groupIdcom.alibaba/groupId artifactIdeasyexcel/artifactId version2.4.6/version !-- 使用最新版本 -- /dependency 2. 创建数据模型 在进行表格导出之前首先需要创建一个数据模型类用来表示你要导出的数据。这个数据模型类中可以使用 EasyExcel 提供的注解来标识 Excel 中的各个字段以及指定一些特性比如日期格式、转换器等。 实体类:需要导出的表格样式在这里使用注解设置,比如表格宽度高度字体颜色等 package cn.ejar.cnos.management.system.api.response.usermeeting;import cn.ejar.cnos.management.system.api.util.excel.GenderConverter; import cn.ejar.cnos.management.system.api.util.excel.LocalDateTimeConverter; import cn.ejar.cnos.management.system.api.util.excel.YesOrNotConverter; 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 lombok.Data;import java.io.Serial; import java.io.Serializable; import java.time.LocalDateTime;Data ContentRowHeight(20) HeadRowHeight(20) ColumnWidth(12) public class UserMeetingVO implements Serializable {Serialprivate static final long serialVersionUID 3607872979830959632L;//用户账号ExcelProperty(用户账号)private String mobile;/*** 用户姓名*/ExcelProperty(用户姓名)private String userName;/*** 性别 1.男 2.女*/ExcelProperty(value 性别, converter GenderConverter.class)private Integer sex;/*** 联系电话*/ExcelProperty(联系电话)private String phone;/*** 所属机构*/ExcelProperty(所属机构)private String affiliatedOrganization;/*** 出行起点*/ExcelProperty(出行起点)private String departurePoint;/*** 出行方式*/ExcelProperty(出行方式)private String travelMode;/*** 是否需要住宿 1.是 2.否*/ExcelProperty(value 是否住宿,converter YesOrNotConverter.class)private Integer isRequired;/*** 预计住宿时间*/ColumnWidth(17)ExcelProperty(住宿时间(晚))private Integer estimatedLengthOfStay;/*** 报名时间*/ColumnWidth(16)ExcelProperty(value 报名时间,converter LocalDateTimeConverter.class)private LocalDateTime createTime;/*** 是否签到 1.是 2.否*/ExcelProperty(value 是否签到,converter YesOrNotConverter.class)private Integer isSignIn;/*** 签到时间*/ColumnWidth(16)ExcelProperty(value 签到时间,converter LocalDateTimeConverter.class)private LocalDateTime signTime;/*** 备注*/ExcelProperty(备注)private String remark; }转换类:提供了很多的转换类共大家使用,也可以自定义转换类,比如有一些字段是使用枚举值存在数据库,但是导出的时候需要导出中文,这时候就可以指定转换器  以下是我的一个例子 package cn.ejar.cnos.management.system.api.util.excel;import com.alibaba.excel.converters.Converter; import com.alibaba.excel.metadata.GlobalConfiguration; import com.alibaba.excel.metadata.data.WriteCellData; import com.alibaba.excel.metadata.property.ExcelContentProperty;/*** 性别转换器** author Jerry* date 2024/04/10*/ public class GenderConverter implements ConverterInteger {Overridepublic WriteCellData? convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {//1.男 2.女if (value null) {return new WriteCellData();} else if (value 1) {return new WriteCellData(男);} else if (value 2) {return new WriteCellData(女);} else {return new WriteCellData(状态异常);}} }工具类: package cn.ejar.cnos.management.system.api.util.excel;import com.alibaba.excel.EasyExcel; import com.alibaba.excel.converters.longconverter.LongStringConverter; import com.alibaba.excel.util.DateUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils;import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Date; import java.util.List;/*** Excel工具类**/ public class ExcelUtils {/*** Excel导出** param response response* param fileName 文件名* param sheetName sheetName* param list 数据List* param pojoClass 对象Class*/public static void exportExcel(HttpServletResponse response, String fileName, String sheetName, List? list,Class? pojoClass) throws IOException {if(StringUtils.isBlank(fileName)){//当前日期fileName DateUtils.format(new Date());}response.setContentType(application/vnd.ms-excel);response.setCharacterEncoding(UTF-8);fileName URLEncoder.encode(fileName, UTF-8);response.setHeader(Content-disposition, attachment;filename fileName .xlsx);EasyExcel.write(response.getOutputStream(), pojoClass).registerConverter(new LongStringConverter()).sheet(sheetName).doWrite(list);}/*** Excel导出先sourceList转换成ListtargetClass再导出** param response response* param fileName 文件名* param sheetName sheetName* param sourceList 原数据List* param targetClass 目标对象Class*/public static void exportExcelToTarget(HttpServletResponse response, String fileName, String sheetName, List? sourceList,Class? targetClass) throws Exception {List targetList new ArrayList(sourceList.size());for(Object source : sourceList){Object target targetClass.newInstance();BeanUtils.copyProperties(source, target);targetList.add(target);}exportExcel(response, fileName, sheetName, targetList, targetClass);} }导出方法: public void export( HttpServletResponse response) throws Exception {ListUserMeetingDTO list new arrayList();ExcelUtils.exportExcelToTarget(response, 报名统计, 报名统计, list, UserMeetingVO.class);} 导出结果: 有任何不懂的地方可以评论区或者私信我,每天都会看博客.
http://www.pierceye.com/news/628454/

相关文章:

  • 网站建设战略互动模板wordpress
  • 三原网站建设网易企业邮箱登录v
  • 为网站营销好处wordpress tar.xz
  • wordpress建站比较淘宝客网站怎么建设
  • 网站结构有哪些安徽省建设工程信息网官方网站
  • 如何查看网站是否备案直播网站怎么做啊
  • 广西做网站的公司投资融资理财网站模板
  • 做网站的颜色游戏推广员拉人犯法吗
  • 金融审核网站制作站长之家网址ip查询
  • 石家庄做家教网站网络营销网站建设
  • 怎么做淘宝网站赚钱吗怎样提高百度推广排名
  • 购物网站建设成本u9u8网站建设
  • 抚州市住房和城乡建设局网站手机网站素材
  • 用dw做音乐网站模板策划公司收费明细
  • 大气手机网站模板免费下载南昌seo排名
  • 做卖衣服网站源代码seo搜索引擎优化名词解释
  • 东营免费建网站网络运维必备知识
  • 盐城建设网站备案 网站负责人
  • 外贸营销网站怎么建设网站域名注册证书
  • 安徽网站建设首选-晨飞网络甘肃泾川县门户网站两学一做
  • 360°网站标签旋转显示特效建筑设计专业比较好的学校
  • 郫县建设局网站中文wordpress模版
  • 塔里木油田公司档案馆网站建设研究响应式网站建设教程
  • wordpress侧边栏怎么加php代码重庆seo优化公司
  • 自做建材配送网站做的比较好的游戏网站
  • 建设网站公司兴田德润在哪里秦皇岛海港区
  • 做网站阜阳百度投放广告
  • 北京互联网金融公司排名网站栏目优化
  • 教育网站解决方案用wordpress制作表单
  • 整站wordpress下载phpcms 网站标题