怎样做 网站做seoasp网页制作

bicheng/2026/1/21 23:52:20/文章来源:
怎样做 网站做seo,asp网页制作,wordpress侧边栏编辑,旅游电子商务的三创赛网站建设目录 一、首先引入依赖 二、然后封装一个VO 三、Controller层 四、Service实现类 引用样式 自适应列宽 自适应行高 五、测试 postman ​编辑 浏览器 异常 分配到这个任务了#xff0c;写个小demo记录下#xff0c;具体可参考EasyExcel官方文档 我用的是web上传…目录 一、首先引入依赖 二、然后封装一个VO 三、Controller层 四、Service实现类  引用样式 自适应列宽   自适应行高 五、测试 postman ​编辑 浏览器 异常 分配到这个任务了写个小demo记录下具体可参考EasyExcel官方文档 我用的是web上传、下载那块代码 一、首先引入依赖 !-- easy Excel --dependencygroupIdcom.alibaba/groupIdartifactIdeasyexcel/artifactIdversion3.1.0/versionexclusionsexclusionartifactIdpoi-ooxml-schemas/artifactIdgroupIdorg.apache.poi/groupId/exclusion/exclusions/dependency 二、然后封装一个VO Data AllArgsConstructor NoArgsConstructor EqualsAndHashCode public class ExportStudentInfoVO implements Serializable {private static final long serialVersionUID -3275970951989418695L;ExcelIgnore // 忽略导出private String stuId;ExcelProperty(学生姓名)private String stuName;ExcelProperty(学生性别)private String stuGender;ExcelProperty(学生年龄)private Integer stuAge;ExcelProperty(监护人联系方式)private String guardianPhone;DateTimeFormat(yyyy-MM-dd HH:mm:ss)ColumnWidth(21) //设置宽度ExcelProperty(value 入学时间)private Date createDate; }三、Controller层 RestController RequestMapping(info) public class InfoController {Resourceprivate InfoService infoService;Operation(summary 学生信息导出)RequestMapping(value /excelDownload, method RequestMethod.GET, produces application/json; charsetutf-8)public void excelOrderContainerDownload(HttpServletResponse response){infoService.excelDownload(response);}} 四、Service实现类  这里的list模拟从DB中查到的数据 .registerWriteHandler(new CustomCellWriteWidthConfig()) /*自适应列宽*/  .registerWriteHandler(new CustomCellWriteHeightConfig()) /*自适应行高*/ .registerWriteHandler(EasyExcelUtils.getStyleStrategy()) /*引用样式*/ 以上三个是excel表格进行一个处理让其看起来更加美观如果要使用可以往下翻对应的代码复制使用不加也不影响导出 Service Slf4j public class InfoServiceImpl implements InfoService {Overridepublic void excelDownload(HttpServletResponse response) {ListExportStudentInfoVO list new ArrayList();list.add(new ExportStudentInfoVO(001,张三,男,18,18488789989, new Date()));list.add(new ExportStudentInfoVO(002,李四,女,21,15233337777, new Date()));list.add(new ExportStudentInfoVO(003,王五,男,19,15623332333, new Date()));try {response.setContentType(application/vnd.openxmlformats-officedocument.spreadsheetml.sheet);response.setCharacterEncoding(utf-8);SimpleDateFormat sdf new SimpleDateFormat(yyyy.MM.dd);String currentDate sdf.format(new Date());// URLEncoder.encode 可以防止中文乱码String fileName URLEncoder.encode(学生信息列表 currentDate, UTF-8).replaceAll(\\, %20);response.setHeader(Content-disposition, attachment;filename*utf-8 fileName .xlsx);EasyExcel.write(response.getOutputStream(), ExportStudentInfoVO.class).sheet(学生信息).registerWriteHandler(new CustomCellWriteWidthConfig()) /*自适应列宽*/.registerWriteHandler(new CustomCellWriteHeightConfig()) /*自适应行高*/.registerWriteHandler(EasyExcelUtils.getStyleStrategy()) /*引用样式*/.doWrite(list);} catch (Exception e) {log.error(导出失败~);e.printStackTrace();}}} 引用样式 package cn.homed.common.utils.excel;import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.metadata.style.WriteFont; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.VerticalAlignment;public class EasyExcelUtils {/*** 设置excel样式*/public static HorizontalCellStyleStrategy getStyleStrategy() {// 头的策略 样式调整WriteCellStyle headWriteCellStyle new WriteCellStyle();// 头背景 浅绿headWriteCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());WriteFont headWriteFont new WriteFont();// 头字号headWriteFont.setFontHeightInPoints((short) 12);// 字体样式headWriteFont.setFontName(宋体);headWriteCellStyle.setWriteFont(headWriteFont);// 自动换行headWriteCellStyle.setWrapped(true);// 设置细边框headWriteCellStyle.setBorderBottom(BorderStyle.THIN);headWriteCellStyle.setBorderLeft(BorderStyle.THIN);headWriteCellStyle.setBorderRight(BorderStyle.THIN);headWriteCellStyle.setBorderTop(BorderStyle.THIN);// 设置边框颜色 25灰度headWriteCellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());headWriteCellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());headWriteCellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());headWriteCellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());// 水平对齐方式headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// 垂直对齐方式headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 内容的策略 宋体WriteCellStyle contentStyle new WriteCellStyle();// 设置垂直居中contentStyle.setWrapped(true);contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置 水平居中 // contentStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);WriteFont contentWriteFont new WriteFont();// 内容字号contentWriteFont.setFontHeightInPoints((short) 12);// 字体样式contentWriteFont.setFontName(宋体);contentStyle.setWriteFont(contentWriteFont);// 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现return new HorizontalCellStyleStrategy(headWriteCellStyle, contentStyle);} } 自适应列宽   package cn.homed.common.utils.excel;import com.alibaba.excel.enums.CellDataTypeEnum; import com.alibaba.excel.metadata.Head; import com.alibaba.excel.metadata.data.CellData; import com.alibaba.excel.metadata.data.WriteCellData; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; import org.apache.commons.collections.CollectionUtils; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Sheet;import java.util.HashMap; import java.util.List; import java.util.Map;public class CustomCellWriteWidthConfig extends AbstractColumnWidthStyleStrategy {private final MapInteger, MapInteger, Integer CACHE new HashMap();Overrideprotected void setColumnWidth(WriteSheetHolder writeSheetHolder, ListWriteCellData? cellDataList, Cell cell, Head head, Integer integer, Boolean isHead) {boolean needSetWidth isHead || !CollectionUtils.isEmpty(cellDataList);if (needSetWidth) {MapInteger, Integer maxColumnWidthMap CACHE.computeIfAbsent(writeSheetHolder.getSheetNo(), k - new HashMap());Integer columnWidth this.dataLength(cellDataList, cell, isHead);// 单元格文本长度大于60换行if (columnWidth 0) {if (columnWidth 60) {columnWidth 60;}Integer maxColumnWidth maxColumnWidthMap.get(cell.getColumnIndex());if (maxColumnWidth null || columnWidth maxColumnWidth) {maxColumnWidthMap.put(cell.getColumnIndex(), columnWidth);Sheet sheet writeSheetHolder.getSheet();sheet.setColumnWidth(cell.getColumnIndex(), columnWidth * 256);}}}}/*** 计算长度* param cellDataList* param cell* param isHead* return*/private Integer dataLength(ListWriteCellData? cellDataList, Cell cell, Boolean isHead) {if (isHead) {return cell.getStringCellValue().getBytes().length;} else {CellData? cellData cellDataList.get(0);CellDataTypeEnum type cellData.getType();if (type null) {return -1;} else {switch (type) {case STRING:// 换行符数据需要提前解析好int index cellData.getStringValue().indexOf(\n);return index ! -1 ?cellData.getStringValue().substring(0, index).getBytes().length 1 : cellData.getStringValue().getBytes().length 1;case BOOLEAN:return cellData.getBooleanValue().toString().getBytes().length;case NUMBER:return cellData.getNumberValue().toString().getBytes().length;default:return -1;}}}} } 自适应行高 package cn.homed.common.utils.excel;import com.alibaba.excel.write.style.row.AbstractRowHeightStyleStrategy; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row;import java.util.Iterator;public class CustomCellWriteHeightConfig extends AbstractRowHeightStyleStrategy {/*** 默认高度*/private static final Integer DEFAULT_HEIGHT 300;Overrideprotected void setHeadColumnHeight(Row row, int relativeRowIndex) {}Overrideprotected void setContentColumnHeight(Row row, int relativeRowIndex) {IteratorCell cellIterator row.cellIterator();if (!cellIterator.hasNext()) {return;}// 默认为 1行高度int maxHeight 1;while (cellIterator.hasNext()) {Cell cell cellIterator.next();if (cell.getCellTypeEnum() CellType.STRING) {String value cell.getStringCellValue();int len value.length();int num 0;if (len 50) {num len % 50 0 ? len / 50 : len / 2 - 1;}if (num 0) {for (int i 0; i num; i) {value value.substring(0, (i 1) * 50 i) \n value.substring((i 1) * 50 i, len i);}}if (value.contains(\n)) {int length value.split(\n).length;maxHeight Math.max(maxHeight, length) 1;}}}row.setHeight((short) ((maxHeight) * DEFAULT_HEIGHT));} } 五、测试 测试的话可以用postman进行测试 或者把链接粘在浏览器上 postman postman测试的时候记得点这个下拉框选择发送并下载 然后弹出这个界面点击保存 然后桌面上就可以看到已经成功的下载下来了数据也都是没问题的 浏览器 直接贴链接即可 可以看到数据也是没问题的  异常 最后讲一下刚开始我这个小demo没跑起来编译、运行都没问题一调接口就报错了 异常是 com.alibaba.excel.exception.ExcelGenerateException: java.lang.NoClassDefFoundError: org/apache/xmlbeans/impl/common/SystemCache 搜了一下是由于缺少了相关的依赖库或者版本不匹配所致可能需要添加 Apache POI 或者 XMLBeans 这些依赖库并且确保版本号是兼容的。 然后加上这两个依赖就可以了不知道你们有没有遇到 dependencygroupIdorg.apache.poi/groupIdartifactIdpoi/artifactIdversion4.1.2/version/dependencydependencygroupIdorg.apache.poi/groupIdartifactIdpoi-ooxml/artifactIdversion4.1.2/version/dependency 好了分享就到这里晚安

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/88028.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

标书制作公司网站触屏网站开发

#暑假到了,作为可能是最后一个快乐的暑假,我打算学点技能来傍身,首先,开始PS之旅 这个帖子作为我跟着B站up主学习PS的记录吧,希望我可以坚持下去! 学习的链接在这里:A02-PS软件安装&#xff0…

深圳建设资源交易服务中心网站网站开发公司组织架构

NodeJS 作为后端,仅在需要时调用 Python 在某些特殊的场景下,比如复杂耗时的数据处理和运算时,我们可以用 Python 脚本编写,然后使用 Node 的子进程调用 Python 脚本即可,这样可以提升效率。如下代码,我们…

网站建设怎么赚钱做外贸电商网站有哪个

Gitlab添加钩子 测试钩子 添加完成后,下面会出现钩子选择。点击test中的,push event。 出现successful,既添加成功。 如果添加失败,报错,更改Network

网站锚文本与标签专门做同人h的网站

AI Agnt是什么 AI代理(AI Agent)是指一种利用人工智能技术来执行特定任务或解决特定问题的自主软件程序。这些代理通过学习和模拟人类行为或特定领域的知识,能够在无需人为干预的情况下完成复杂的任务。AI代理广泛应用于多个领域&#xff0c…

深圳涂料网站建设平面设计哪个网站素材好

全文链接:http://tecdat.cn/?p32496 人口流动与迁移,作为人类产生以来就存在的一种社会现象,伴随着人类文明的不断进步从未间断(点击文末“阅读原文”获取完整代码数据)。 相关视频 人力资源是社会文明进步、人民富裕…

在深圳帮人做网站做网站的公司都有哪些岗位

概述 近期一直在负责es这块,就想着和大家分享一些使用经验,我们从存储、查询、优化、备份、运维等几个方面来做分享。今天咱们先看下如何更加合理的存储数据。 初见索引模板 记得刚接触es还是18年那会,项目上线后因一些原因导致日志这部分的…

自己做的网站怎么传到空间啊电商网站开发文档

银河麒麟v10 二进制安装包 安装mysql 8.35 1、卸载mariadb2、下载Mysql安装包3、安装Mysql 8.353.1、安装依赖包3.2、安装Mysql3.3、安装后配置 1、卸载mariadb 由于银河麒麟v10系统默认安装了mariadb 会与Mysql相冲突,因此首先需要卸载系统自带的mariadb 查看系统…

承德企业网站建设wordpress文章美观

目录 1.前言 2.本地安装和设置SQL Server 2.1 SQL Server下载 2.2 SQL Server本地连接测试 2.3 Cpolar内网穿透的下载和安装 2.3 Cpolar内网穿透的注册 3.本地网页发布 3.1 Cpolar云端设置 3.2 Cpolar本地设置 4.公网访问测试 5.结语 1.前言 数据库的重要性相信大家…

智能化建设网站深圳网站建设公司 概况

目录 前言: 一、什么是线程 (一)基本概念 (二)线程理解 (三)线程与进程的关系 (四)简单实用线程 (五)重谈虚拟地址空间 1. 页表的大小 2…

茂名免费自助建站模板网站域名查询ip地址

链接:http://www.cnblogs.com/BeyondAnyTime/archive/2012/05/23/2514964.html

网站开发成本预算吴川市建设工程公司网站

Title 题目 Improved breast cancer histological grading using deep learning 使用深度学习改善乳腺癌组织学分级 01 文献速递介绍 乳腺癌组织学分级是乳腺癌中一个确立的临床变量,它包括来自三个方面的信息,即小管形成程度、核多态性和有丝分裂计…

邢台营销型网站制作邢台邯郸做网站

📝前言: 这篇文章主要讲解一下条件判断语句if和循环语句while,for在python中需要注意的地方。 建议已有一定了解(对语句的执行逻辑清楚)的读者观看,如果对条件判断和循环的执行逻辑不太清楚,也可…

手机网站域名哪里注册番禺品牌型网站

对象的克隆 1、克隆即复制的意思,对象的克隆,意味着生成一个对象,这个对象和某个对象的属性和行为是一致的,但是这个对象和源对象是两个不同的对象。实现对象的克隆,方法是实现Cloneable接口,否则会报异常C…

网站销售流程邹平建设局网站

实现的基本功能: 登录时,需要输入姓名,然后选择作为管理者还是普通用户。选择成功后选择想要实现的功能。管理者的目录下方有有五个功能,而普通用户有4个功能,如下图 首先我们要建立Book这个类,里面包含书…

哪个通讯公司的网络好合肥优化营商环境

LOGO是一个网站的形象代表或者说是品牌的象征,用户记住了网站LOGO,就相当于记住了网站,因此,自己建网站时要融入网站LOGO的设计,潜移默化地把LOGO形象植入用户脑海中,把网站与LOGO紧密连接在一起&#xff0…

做公司的网站大概多少钱湖南省建设厅纪检组长

基于Spring Boot的夕阳红公寓管理系统的设计与实现 摘 要 如今社会上各行各业,都在用属于自己专用的软件来进行工作,互联网发展到这个时候,人们已经发现离不开了互联网。互联网的发展,离不开一些新的技术,而新技术的…

阿里云做企业网站西部数码网站管理助手 卸载

OpenFireOpenFire 是采用Java开发的基于XMPP(Jabber)协议,开源实时协作(RTC)服务器。Smack 是用 Java编 写的XMPP客户端代码库,是 spark 的核心开源界总是有许多有趣的东东,这三个合起来就是一个完整的XMPP IM 实现。OpenFire ——服务器端Sp…

农产品网站建设的主要工作营销推广策划及渠道

摘要:开发高效的夜视行人检测系统对于提升夜间安全和监控效能至关重要。本篇博客详尽介绍了如何利用深度学习技术搭建一个夜视行人检测系统,并提供了完整的实现代码。本系统采用了先进的YOLOv8算法,并与YOLOv7、YOLOv6、YOLOv5进行了性能比较…

网站建设咨询宿迁房价下跌最惨小区

引言 最近在研究Vue打包成app,给我的报价器搞一个移动端,奈何没有安卓手机用于测试。所以想到安装一个安卓模拟器。 看了下目前主流的安卓模拟器基本都不支持Mac版本。网易的mumu目前来看还是只支持Intel芯。 1. 简单版(仅M系)…

建设网站困难的解决办法建设集团属于什么单位

以下示例显示如何获取选定的行或选定的列,或如何选择JTable组件中的多个单元格。要侦听选择事件,我们可以JTable通过调用JTable.getSelectionModel().addListSelectionListener()方法将选择侦听器添加到组件。该方法接受实现ListSelectionListener接口的…