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

【EasyExcel】复杂导出操作-自定义颜色样式等(版本3.1.x)

文章目录

  • 前言
  • 一、自定义拦截器
  • 二、自定义操作
    • 1.自定义颜色
    • 2.合并单元格
  • 三、复杂操作示例
    • 1.实体(使用了注解式样式):
    • 2.自定义拦截器
    • 3.代码
    • 4.最终效果


前言

本文简单介绍阿里的EasyExcel的复杂导出操作,包括自定义样式,根据数据合并单元格等。

点击查看EasyExcel官方文档


一、自定义拦截器

要实现复杂导出,靠现有的拦截器怕是不大够用,EasyExcel 已经有提供部分像是 自定义样式的策略HorizontalCellStyleStrategy
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
通过源码,我们不难发现其原理正是实现了拦截器接口,使用了afterCellDispose方法,在数据写入单元格后会调用该方法,因此,需要进行复杂操作,我们需要自定义拦截器,在afterCellDispose方法进行逻辑处理,其中我们可以通过context参数获取到表,行,列及单元格数据等信息:
在这里插入图片描述

二、自定义操作

1.自定义颜色

由于WriteCellStyle 及CellStyle接口的设置单元格背景颜色方法setFillForegroundColor不支持自定义颜色,我在网上找了半天,以及询问阿里自家ai助手通义得到的答案都是往里塞一个XSSFColor这样的答案,但这个方法传参是一个short类型的index呀,是预设好的颜色,里面也没有找到其他重载方法。(这里针对的是导出xlsx文件)

在这里插入图片描述

而真正可以自定义颜色的是XSSFCellStyle类,XSSFCellStyle实现CellStyle接口,并重载了该方法,于是我们只需要在workbook.createCellStyle()的时候将其强转为XSSFCellStyle:

// 将背景设置成浅蓝色
XSSFColor customColor = new XSSFColor(new java.awt.Color(181, 198, 234), null);
XSSFCellStyle style = (XSSFCellStyle)workbook.createCellStyle();
style.setFillForegroundColor(customColor);
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(style);

在idea我们可以使用 ctrl + alt + 鼠标点击接口,来查看接口的所有实现类(HSSF是针对xls的):

在这里插入图片描述

然而在我们自定义的拦截器中,操作当前单元格样式时会无法生效,这是因为在3.1.x版本后有一个FillStyleCellWriteHandler拦截器,他会把OriginCellStyle和WriteCellStyle合并,会已WriteCellStyle样式为主,他的order是50000,而我们自定义的拦截器默认是0,因此我们修改的样式会被覆盖。
在这里插入图片描述
在这里插入图片描述
解决方法很简单,我们可以在我们的自定义拦截器重写order方法,将其值设置大于50000即可

  @Overridepublic int order() {return 50001;}

如果你没有使用自定义拦截器(如HorizontalCellStyleStrategy )以及没有设置WriteCellStyle 样式,则还可以将ignoreFillStyle置为true,

 @Overridepublic void afterCellDispose(CellWriteHandlerContext context) {context.setIgnoreFillStyle(true);// 做其他样式操作}

2.合并单元格

 ```java@Overridepublic void afterCellDispose(CellWriteHandlerContext context) {// 判断当前为表头,不执行操作if (isHead) {log.info("\r\n当前为表头, 不执行操作");return;}// 获取当前单元格context.getCell()// 当前 SheetSheet sheet = cell.getSheet();// 当前单元格所在行索引int rowIndexCurr = cell.getRowIndex();// 当前单元格所在列索引int columnIndex = cell.getColumnIndex();// 当前单元格所在行的上一行索引int rowIndexPrev = rowIndexCurr - 1;// 当前单元格所在行的 Row 对象Row rowCurr = cell.getRow();// 当前单元格所在行的上一行 Row 对象Row rowPrev = sheet.getRow(rowIndexPrev);// 当前单元格的上一行同列单元格Cell cellPrev = rowPrev.getCell(columnIndex);// 合并同列不同行的相邻两个单元格sheet.addMergedRegion(new CellRangeAddress(rowIndexPrev, rowIndexCurr,columnIndex, columnIndex));}

需要注意的是,如果要合并的单元格已经被其他单元格合并过,则不能直接使用这个合并方法,需要先解除合并,再进行组合合并:

 // 从 Sheet 中,获取所有合并区域List<CellRangeAddress> mergedRegions = sheet.getMergedRegions();// 判断是否合并过boolean merged = false;// 遍历合并区域集合for (int i = 0; i < mergedRegions.size(); i++) {CellRangeAddress cellAddresses = mergedRegions.get(i);// 判断 cellAddress 的范围是否是从 rowIndexPrev 到 cell.getColumnIndex()if (cellAddresses.isInRange(rowIndexPrev, cell.getColumnIndex())) {// 解除合并sheet.removeMergedRegion(i);// 设置范围最后一行,为当前行cellAddresses.setLastRow(rowIndexCurr);// 重新进行合并sheet.addMergedRegion(cellAddresses);merged = true;break;}}// merged=false,表示当前单元格为第一次合并if (!merged) {CellRangeAddress cellAddresses = new CellRangeAddress(rowIndexPrev, rowIndexCurr, cell.getColumnIndex(), cell.getColumnIndex());sheet.addMergedRegion(cellAddresses);}

三、复杂操作示例

自定义拦截器代码如下(示例):

1.实体(使用了注解式样式):

package com.mhqs.demo.tool.easyExcel.entity;import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentFontStyle;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import lombok.EqualsAndHashCode;import java.math.BigDecimal;/*** 账单实体类* @author 棉花* */
@Data
@EqualsAndHashCode(callSuper = false)
@HeadFontStyle(fontHeightInPoints = 10)
@HeadRowHeight(27)
@ColumnWidth(13)
@ContentFontStyle(fontName = "宋体",fontHeightInPoints = 11)
public class DemoEntity extends EasyExcelEntity {@ExcelProperty({"账期"})private String settlePeriod;@ExcelProperty({"服务商"})private String stockCreatorMchid;@ExcelProperty({"地区"})private String place;@ExcelProperty({"金额(元)"})private BigDecimal consumeAmount;public DemoEntity(String settlePeriod, String stockCreatorMchid,String place, BigDecimal consumeAmount){this.settlePeriod = settlePeriod;this.stockCreatorMchid = stockCreatorMchid;this.place = place;this.consumeAmount = consumeAmount;}}

2.自定义拦截器

package com.mhqs.demo.tool.easyExcel.handler;import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.util.StyleUtil;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.mhqs.demo.tool.easyExcel.entity.DemoEntity;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;import java.math.BigDecimal;
import java.util.*;/*** @author bcb* 账单导出样式处理*/
public class CustomCellWriteHandler implements CellWriteHandler {/*** 自定义颜色*/private final java.awt.Color color;/*** 自定义颜色样式*/private CellStyle colorfulCellStyle;/*** 自定义特殊金额样式*/private CellStyle specialCellStyle;/*** 头样式*/private final WriteCellStyle headWriteCellStyle;/*** 内容样式*/private final WriteCellStyle contentWriteCellStyle;/*** 头样式(可自定义颜色)*/private CellStyle headCellStyle;/*** 内容样式(可自定义颜色)*/private CellStyle contentCellStyle;public CustomCellWriteHandler(WriteCellStyle headWriteCellStyle,WriteCellStyle contentWriteCellStyle, java.awt.Color color) {this.headWriteCellStyle = headWriteCellStyle;this.contentWriteCellStyle = contentWriteCellStyle;this.color = color;}@Overridepublic void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {// 在创建单元格之前的操作(如果需要)Workbook workbook = writeSheetHolder.getSheet().getWorkbook();if (colorfulCellStyle == null) {colorfulCellStyle = createColorfulCellStyle(workbook);}// 合并样式(以WriteCellStyle为主)headCellStyle = StyleUtil.buildCellStyle(workbook, colorfulCellStyle, headWriteCellStyle);contentCellStyle = StyleUtil.buildCellStyle(workbook, workbook.createCellStyle(), contentWriteCellStyle);}/** 创建自定义颜色样式*/private CellStyle createColorfulCellStyle(Workbook workbook) {XSSFColor customColor = new XSSFColor(color, null);XSSFCellStyle style = (XSSFCellStyle)workbook.createCellStyle();// 设置自定义颜色style.setFillForegroundColor(customColor);style.setFillPattern(FillPatternType.SOLID_FOREGROUND);// 设置边框style.setBorderTop(BorderStyle.THIN);style.setBorderBottom(BorderStyle.THIN);style.setBorderLeft(BorderStyle.THIN);style.setBorderRight(BorderStyle.THIN);// 设置垂直对齐方式style.setVerticalAlignment(VerticalAlignment.CENTER);// 设置水平对齐方式style.setAlignment(HorizontalAlignment.CENTER);return style;}/** 创建自定义特殊金额样式*/private CellStyle createSpecialCellStyle(Workbook workbook) {if (specialCellStyle == null) {XSSFCellStyle style = (XSSFCellStyle)createColorfulCellStyle(workbook);Font font = workbook.createFont();// 字体加粗font.setBold(true);style.setFont(font);specialCellStyle = style;}return specialCellStyle;}/*** 在 Cell 写入后处理** @param writeSheetHolder* @param writeTableHolder* @param cellDataList* @param cell               当前 Cell* @param head* @param relativeRowIndex   表格内容行索引,从除表头的第一行开始,索引为0* @param isHead             是否是表头,true表头,false非表头*/@Overridepublic void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder,List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {// 当前 SheetSheet sheet = cell.getSheet();// 判断当前为表头,执行对应样式操作if (isHead) {cell.setCellStyle(headCellStyle);} else {cell.setCellStyle(contentCellStyle);}// 判断当前为表头,不执行操作if (isHead || relativeRowIndex == 0) {return;}int columnIndex = cell.getColumnIndex();// 当前 Cell 所在行索引int rowIndexCurr = cell.getRowIndex();// 当前 Cell 所在行的上一行索引int rowIndexPrev = rowIndexCurr - 1;// 当前 Cell 所在行的 Row 对象Row rowCurr = cell.getRow();// 当前 Cell 所在行的上一行 Row 对象Row rowPrev = sheet.getRow(rowIndexPrev);// 当前单元格的上一行同列单元格Cell cellPrev = rowPrev.getCell(columnIndex);// 当前单元格的值Object cellValueCurr = cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue();if (columnIndex == 3 && cellValueCurr != null && (double)cellValueCurr > 200) {// 判断金额大于200就设置特定颜色并加粗,并将上一列同一行的数据也设置特定颜色CellStyle cellStyle = createSpecialCellStyle(sheet.getWorkbook());cell.setCellStyle(cellStyle);// 当前单元格的同行上一列单元格Cell cellPreC = rowCurr.getCell(columnIndex - 1);cellPreC.setCellStyle(colorfulCellStyle);}// 上面单元格的值Object cellValuePrev = cellPrev.getCellType() == CellType.STRING ? cellPrev.getStringCellValue() : cellPrev.getNumericCellValue();/** 只判断前两列相同行数据*/if (columnIndex != 0 && columnIndex != 1) {return;}// 判断当前单元格与上面单元格是否相等,不相等不执行操作if (!cellValueCurr.equals(cellValuePrev)) {return;}/** 当第一列上下两个单元格不一样时,说明不是一个账期数据*/if (!rowPrev.getCell(0).getStringCellValue().equals(rowCurr.getCell(0).getStringCellValue())) {return;}// 从 Sheet 中,获取所有合并区域List<CellRangeAddress> mergedRegions = sheet.getMergedRegions();// 是否合并过boolean merged = false;// 遍历合并区域集合for (int i = 0; i < mergedRegions.size(); i++) {CellRangeAddress cellAddresses = mergedRegions.get(i);//判断 cellAddress 的范围是否是从 rowIndexPrev 到 cell.getColumnIndex()if (cellAddresses.isInRange(rowIndexPrev, columnIndex)) {// 从集合中移除sheet.removeMergedRegion(i);// 设置范围最后一行,为当前行cellAddresses.setLastRow(rowIndexCurr);// 重新添加到 Sheet 中sheet.addMergedRegion(cellAddresses);// 已完成合并merged = true;break;}}// merged=false,表示当前单元格为第一次合并if (!merged) {CellRangeAddress cellAddresses = new CellRangeAddress(rowIndexPrev, rowIndexCurr, columnIndex, columnIndex);sheet.addMergedRegion(cellAddresses);}}/*** 获取当前处理器优先级*/@Overridepublic int order() {return 50001;}}

3.代码

public static void main(String[] args) {String fileName = "D:\\temp\\账单.xlsx";// 设置 Cell 样式WriteCellStyle writeCellStyle = new WriteCellStyle();// 设置垂直对齐方式writeCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 设置水平对齐方式writeCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// 设置边框writeCellStyle.setBorderTop(BorderStyle.THIN);writeCellStyle.setBorderBottom(BorderStyle.THIN);writeCellStyle.setBorderLeft(BorderStyle.THIN);writeCellStyle.setBorderRight(BorderStyle.THIN);// 自定义颜色java.awt.Color color = new java.awt.Color(181, 198, 234);List<DemoEntity> dataList = new ArrayList<>();for (int i = 0; i < 5; i++) {dataList.add(new DemoEntity("202301","服务商" + i%2,"地区" + i,new BigDecimal(i * 100)));}dataList.sort(Comparator.comparing(DemoEntity::getSettlePeriod).thenComparing(DemoEntity::getStockCreatorMchid));ExcelWriter excelWriter = EasyExcel.write(fileName, DemoEntity.class).build();WriteSheet writeSheet = EasyExcel.writerSheet(0, "账单").registerWriteHandler(new CustomCellWriteHandler(null,writeCellStyle,color)).build();excelWriter.write(dataList, writeSheet);// 需要多sheet则可以继续// WriteSheet writeSheet2 = EasyExcel.writerSheet(1, "第二个sheet")excelWriter.finish();}

4.最终效果

在这里插入图片描述

待续…


参考文章:
easyexcel 3.1.0+,设置RBG背景颜色
EasyExcel导出多sheet并设置单元格样式
EasyExcel的CellWriteHandler注入CellStyle不生效

相关文章:

【EasyExcel】复杂导出操作-自定义颜色样式等(版本3.1.x)

文章目录 前言一、自定义拦截器二、自定义操作1.自定义颜色2.合并单元格 三、复杂操作示例1.实体(使用了注解式样式)&#xff1a;2.自定义拦截器3.代码4.最终效果 前言 本文简单介绍阿里的EasyExcel的复杂导出操作&#xff0c;包括自定义样式&#xff0c;根据数据合并单元格等。…...

机器学习 ---线性回归

目录 摘要&#xff1a; 一、简单线性回归与多元线性回归 1、简单线性回归 2、多元线性回归 3、残差 二、线性回归的正规方程解 1、线性回归训练流程 2、线性回归的正规方程解 &#xff08;1&#xff09;适用场景 &#xff08;2&#xff09;正规方程解的公式 三、衡量…...

深度学习每周学习总结J5(DenseNet-121 +SE 算法实战与解析 - 猴痘识别)

&#x1f368; 本文为&#x1f517;365天深度学习训练营 中的学习记录博客&#x1f356; 原作者&#xff1a;K同学啊 | 接辅导、项目定制 0. 总结 数据导入及处理部分&#xff1a;本次数据导入没有使用torchvision自带的数据集&#xff0c;需要将原始数据进行处理包括数据导入…...

VBA学习笔记:点击单元格显示指定的列

应用场景&#xff1a; 表格中列数较多&#xff0c;特定条件下隐藏一些无关的列&#xff0c;只保留相关的列&#xff0c;使表格更加清晰。 示例&#xff1a;原表格如下 点击一年级&#xff0c;只显示一年级相关的科目&#xff1a; 点击二年级&#xff0c;只显示二年级相关的科…...

windows C#-LINQ概述

语言集成查询 (LINQ) 是一系列直接将查询功能集成到 C# 语言的技术统称。 数据查询历来都表示为简单的字符串&#xff0c;没有编译时类型检查或 IntelliSense 支持。 此外&#xff0c;需要针对每种类型的数据源了解不同的查询语言&#xff1a;SQL 数据库、XML 文档、各种 Web 服…...

vue项目npm run serve出现【- Network: unavailable】(从排查到放弃)

1. 问题现象 环境&#xff1a; 系统&#xff1a;win11node&#xff1a;v16.20.2“vue”: “2.6.10” 执行npm run serve启动vue项目&#xff0c;期望&#xff1a; App running at:- Local: http://localhost:9528/ - Network: http://x.x.x.x:9528/实际&#xff1a; App runn…...

R语言贝叶斯分析:INLA 、MCMC混合模型、生存分析肿瘤临床试验、间歇泉喷发时间数据应用|附数据代码...

全文链接&#xff1a;https://tecdat.cn/?p38273 多模态数据在统计学中并不罕见&#xff0c;常出现在观测数据来自两个或多个潜在群体或总体的情况。混合模型常用于分析这类数据&#xff0c;它利用不同的组件来对数据中的不同群体或总体进行建模。本质上&#xff0c;混合模型是…...

C++ 关于类与对象(中篇)一篇详解!(运算符重载)

赋值运算符重载 运算符重载 C 为了 增强代码的可读性 引入了运算符重载 &#xff0c; 运算符重载是具有特殊函数名的函数 &#xff0c;也具有其返回值类型&#xff0c;函数名字以及参数列表&#xff0c;其返回值类型与参数列表与普通的函数类似。 函数名字为&#xff1a;关键…...

Scala的set

//Set的特点&#xff1a;唯一&#xff08;元素不相同&#xff09;&#xff1b;无序 case class Book(var bookName:String,var author:String,var price:Double){} object test27 {def main(args: Array[String]): Unit {//定义一个可变setval set1 scala.collection.mutable…...

Linux---常用shell脚本

目录 一.网络服务 开启network服务 网口IP配置 聚合口配置 前言 秋招拿到了科大讯飞的offer&#xff0c;可是由于某些原因无法完成三方签署&#xff0c;心情还是比较失落的&#xff0c;或许写一篇技术博客&#xff0c;活跃一下大脑思维也是一种不错的放松方式。 一.网络服务 …...

windows二进制安全零基础(二)

文章目录 栈&#xff08;The Stack&#xff09;调用约定&#xff08;Calling Conventions&#xff09;函数返回机制 在x86架构中&#xff0c;栈&#xff08;Stack&#xff09;是一个非常重要的内存区域&#xff0c;它用于支持线程的短期数据需求&#xff0c;如函数调用、局部变…...

git常用命令+搭vscode使用

1.克隆远程代码 git clone http:xxx git clone ssh:xxx clone的url 中 https和 ssh是有区别的: git中SSH和HTTP连接有什么区别-CSDN博客 当然https拉下来的代码每次pull /push都需要验证一次自己的账户和密码,可以config进行配置不用每次手敲: 解决VScode中每次git pu…...

如何在C#中处理必盈接口返回的股票数据?

在必盈接口返回股票数据后&#xff0c;在 C# 中可通过以下步骤进行处理&#xff1a; 数据获取 使用 HttpWebRequest 或 HttpClient 类向必盈接口发送请求以获取数据。以 HttpWebRequest 为例&#xff0c;构建请求并发送&#xff0c;获取响应流后读取为字符串形式的 JSON 数据。…...

01 最舒适的python开发环境

0 前言 我自己经过尝试&#xff0c;总结出python3开发环境的最舒适方式。 python3安装创建虚拟环境 venvjupyter notebook 笔记本安装vscode插件(Python, Pylance, Jupyter) 1 python3安装 ubuntu系统下安装最新版本的python3 sudo apt update sudo apt install python32 …...

【PyTorch】libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent

【PyTorch】libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent 1 报错信息2 原因3 解决方法 1 报错信息 conda install pytorch1.13.1 torchaudio0.13.1 torchvision0.14.1 cudatoolkit11.7 -c pytorch在 conda 环境中安装 torch 后测试&#xff0c;得到下面的错误&#x…...

快速利用c语言实现线性表(lineList)

线性表是数据结构中最基本和简单的一个&#xff0c;它是n的相同类型数据的有序序列&#xff0c;我们也可以用c语言中的数组来理解线性表。 一、线性表声明 我们定义一个线性表的结构体&#xff0c;内部有三个元素&#xff1a;其中elem是一个指针&#xff0c;指向线性表的头&am…...

量子计算与人工智能的交汇:科技未来的新引擎

引言 在当今飞速发展的科技世界&#xff0c;人工智能&#xff08;AI&#xff09;和量子计算无疑是最受瞩目的两大前沿领域。人工智能凭借其在数据处理、模式识别以及自动化决策中的强大能力&#xff0c;已经成为推动各行业数字化转型的重要力量。而量子计算则通过颠覆传统计算机…...

51单片机使用NRF24L01进行2.4G无线通信

本文并不打算详细介绍NRF24L01的各个功能寄存器及指令的详细用法&#xff0c;因为网上都可以搜到很多非常详细的教程文档&#xff0c;这里只是介绍一些基本概念、用法以及代码的解释&#xff0c;旨在帮助新手能够快速上手调通快速使用。 基础概念 该模块使用的是SPI协议&…...

HelloMeme 上手即用教程

HelloMeme是一个集成空间编织注意力的扩散模型&#xff0c;用于生成高保真图像和视频。它提供了一个代码库&#xff0c;包含实验代码和预训练模型&#xff0c;支持PyTorch和FFmpeg。用户可以通过简单的命令行操作来生成图像和视频。 本文将详细介绍&#xff0c;如何在GPU算力租…...

自定义call方法和apply方法

自定义call方法 //Fn:要执行的函数&#xff0c;obj&#xff1a;函数中this的指向&#xff0c;args:剩余参数function call(Fn, obj, ...args) {//判断if (obj undefined || obj null) {obj globalThis; //全局对象 globalThis&#xff1a;es11新增的特性&#xff0c;用来指向…...

【Axure高保真原型】引导弹窗

今天和大家中分享引导弹窗的原型模板&#xff0c;载入页面后&#xff0c;会显示引导弹窗&#xff0c;适用于引导用户使用页面&#xff0c;点击完成后&#xff0c;会显示下一个引导弹窗&#xff0c;直至最后一个引导弹窗完成后进入首页。具体效果可以点击下方视频观看或打开下方…...

pam_env.so模块配置解析

在PAM&#xff08;Pluggable Authentication Modules&#xff09;配置中&#xff0c; /etc/pam.d/su 文件相关配置含义如下&#xff1a; 配置解析 auth required pam_env.so1. 字段分解 字段值说明模块类型auth认证类模块&#xff0c;负责验证用户身份&am…...

c++ 面试题(1)-----深度优先搜索(DFS)实现

操作系统&#xff1a;ubuntu22.04 IDE:Visual Studio Code 编程语言&#xff1a;C11 题目描述 地上有一个 m 行 n 列的方格&#xff0c;从坐标 [0,0] 起始。一个机器人可以从某一格移动到上下左右四个格子&#xff0c;但不能进入行坐标和列坐标的数位之和大于 k 的格子。 例…...

多模态商品数据接口:融合图像、语音与文字的下一代商品详情体验

一、多模态商品数据接口的技术架构 &#xff08;一&#xff09;多模态数据融合引擎 跨模态语义对齐 通过Transformer架构实现图像、语音、文字的语义关联。例如&#xff0c;当用户上传一张“蓝色连衣裙”的图片时&#xff0c;接口可自动提取图像中的颜色&#xff08;RGB值&…...

Keil 中设置 STM32 Flash 和 RAM 地址详解

文章目录 Keil 中设置 STM32 Flash 和 RAM 地址详解一、Flash 和 RAM 配置界面(Target 选项卡)1. IROM1(用于配置 Flash)2. IRAM1(用于配置 RAM)二、链接器设置界面(Linker 选项卡)1. 勾选“Use Memory Layout from Target Dialog”2. 查看链接器参数(如果没有勾选上面…...

python爬虫:Newspaper3k 的详细使用(好用的新闻网站文章抓取和解析的Python库)

更多内容请见: 爬虫和逆向教程-专栏介绍和目录 文章目录 一、Newspaper3k 概述1.1 Newspaper3k 介绍1.2 主要功能1.3 典型应用场景1.4 安装二、基本用法2.2 提取单篇文章的内容2.2 处理多篇文档三、高级选项3.1 自定义配置3.2 分析文章情感四、实战案例4.1 构建新闻摘要聚合器…...

Java 加密常用的各种算法及其选择

在数字化时代&#xff0c;数据安全至关重要&#xff0c;Java 作为广泛应用的编程语言&#xff0c;提供了丰富的加密算法来保障数据的保密性、完整性和真实性。了解这些常用加密算法及其适用场景&#xff0c;有助于开发者在不同的业务需求中做出正确的选择。​ 一、对称加密算法…...

QT: `long long` 类型转换为 `QString` 2025.6.5

在 Qt 中&#xff0c;将 long long 类型转换为 QString 可以通过以下两种常用方法实现&#xff1a; 方法 1&#xff1a;使用 QString::number() 直接调用 QString 的静态方法 number()&#xff0c;将数值转换为字符串&#xff1a; long long value 1234567890123456789LL; …...

css3笔记 (1) 自用

outline: none 用于移除元素获得焦点时默认的轮廓线 broder:0 用于移除边框 font-size&#xff1a;0 用于设置字体不显示 list-style: none 消除<li> 标签默认样式 margin: xx auto 版心居中 width:100% 通栏 vertical-align 作用于行内元素 / 表格单元格&#xff…...

docker 部署发现spring.profiles.active 问题

报错&#xff1a; org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property spring.profiles.active imported from location class path resource [application-test.yml] is invalid in a profile specific resource [origin: class path re…...