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

POI 和 EasyExcel 操作 Excel

一、概述

        目前操作 Excel 比较流行的就是 Apache POI 和阿里巴巴的 easyExcel

1.1 POI 简介

        Apache POI 是用 Java 编写的免费开源的跨平台的 Java APIApache POI 提供 API Java 程序对 Microsoft Office 格式文档读和写的常用功能。POI “Poor Obfuscation Implementation” 的首字母缩写,意为“简洁版的模糊实现”。其常用的结构如下:

        HSSF -- 提供读写 03 版本的 Excel 常用功能。

        XSSF -- 提供读写 07 版本的 Excel 常用功能。

        HWPF -- 提供读写 Word 格式的常用功能

        HSLF -- 提供读写 ppt 格式的常用功能。

        HDGF -- 提供读写 visio 格式的常用功能

1.2 easyExcel 简介

        easyExcel 是阿里巴巴开源的一个 excel 处理框架,以使用简单、节省内存著称。easyExcel 能大大减少占用内存的主要原因是在解析 Excel 时没有将文件数据一次性全部加载到内存中,而是从磁盘上一行行读取数据,逐个解析。

        easyExcel 官网地址:https://github.com/alibaba/easyexcel

1.3 xls 和 xlsx 区别

        常用的 excel 文档有两种结尾形式,分别为 xlsxlsx,其中以 xls 结尾的文档属于 03 版本的,它里面最多可以存储 65536 行数据。而以 xlsx 结尾的文档属于 07 版本的,它理论上可以存储无限行数据,这就是两者之前的区别。

二、POI 常用操作

2.1 添加 maven 依赖

    <dependencies><!--xls(03 版本)--><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.9</version></dependency><!--xlsx(07 版本)--><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.9</version></dependency><!-- 日期格式化工具--><dependency><groupId>joda-time</groupId><artifactId>joda-time</artifactId><version>2.10.1</version></dependency><!--test--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency></dependencies>

2.2 写入 Excel 操作

2.2.1 一般文件写入

2.2.1.1 03 版本
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.joda.time.DateTime;
import org.junit.Test;import java.io.FileOutputStream;public class ExcelWriteTest {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testWrite03() throws Exception {// 1、创建一个工作簿Workbook workbook = new HSSFWorkbook();// 2、创建一个工作表Sheet sheet = workbook.createSheet("我是 sheet1 页");// 3、创建一行Row row1  = sheet.createRow(0);// 4、创建一个单元格Cell cell11 = row1.createCell(0);cell11.setCellValue("我是第一行第一个单元格");Cell cell12 = row1.createCell(1);cell12.setCellValue("我是第一行第二个单元格");// 第二行Row row2  = sheet.createRow(1);Cell cell21 = row2.createCell(0);cell21.setCellValue("我是第二行第一个单元格");Cell cell22 = row2.createCell(1);String time = new DateTime().toString("yyyy-MM-dd HH:mm:ss");cell22.setCellValue(time);// 03 版本的使用 xls 结尾FileOutputStream fileOutputStream  = new FileOutputStream(PATH+"统计表03类型.xls");workbook.write(fileOutputStream);fileOutputStream.close();System.out.println("Excel03 写入完成了");}
}

2.2.2.2 07 版本
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.joda.time.DateTime;
import org.junit.Test;import java.io.FileOutputStream;public class ExcelWriteTest {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testWrite07() throws Exception {// 1、创建一个工作簿Workbook workbook = new XSSFWorkbook();// 2、创建一个工作表Sheet sheet = workbook.createSheet("我是 sheet1 页");// 3、创建一行Row row1  = sheet.createRow(0);// 4、创建一个单元格Cell cell11 = row1.createCell(0);cell11.setCellValue("我是第一行第一个单元格");Cell cell12 = row1.createCell(1);cell12.setCellValue("我是第一行第二个单元格");// 第二行Row row2  = sheet.createRow(1);Cell cell21 = row2.createCell(0);cell21.setCellValue("我是第二行第一个单元格");Cell cell22 = row2.createCell(1);String time = new DateTime().toString("yyyy-MM-dd HH:mm:ss");cell22.setCellValue(time);// 07 版本的使用 xlsx 结尾FileOutputStream fileOutputStream  = new FileOutputStream(PATH+"统计表07类型.xlsx");workbook.write(fileOutputStream);fileOutputStream.close();System.out.println("Excel07 写入完成了");}
}

2.2.2 大文件写入

2.2.2.1 03 版本
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;import java.io.FileOutputStream;public class ExcelWriteTest {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testWrite03BigData() throws Exception {long begin = System.currentTimeMillis();// 1、创建一个工作簿Workbook workbook = new HSSFWorkbook();// 2、创建一个工作表Sheet sheet = workbook.createSheet();// 3、写入数据for(int rowNum =0;rowNum<65537;rowNum++){Row row = sheet.createRow(rowNum);for(int cellNum=0;cellNum<10;cellNum++){Cell cell = row.createCell(cellNum);cell.setCellValue(cellNum);}}System.out.println("over");FileOutputStream fileOutputStream  = new FileOutputStream(PATH+"统计表03大数据类型.xls");workbook.write(fileOutputStream);fileOutputStream.close();long end = System.currentTimeMillis();System.out.println((double)(end-begin)/1000);}
}

        缺点:最多只能处理 65536 行,否则会抛出异常。

        优点:写入过程中写入缓存,不操作磁盘,最后一次性写入磁盘,速度快。将 65537 改成65536 再次执行程序,结果如下,可以看到 1.692s 就完成了写入操作,速度还是很快的。

2.2.2.2 07 版本
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;import java.io.FileOutputStream;public class ExcelWriteTest {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testWrite07BigData() throws Exception {long begin = System.currentTimeMillis();// 1、创建一个工作簿Workbook workbook = new XSSFWorkbook();// 2、创建一个工作表Sheet sheet = workbook.createSheet();// 3、写入数据for(int rowNum =0;rowNum<100000;rowNum++){Row row = sheet.createRow(rowNum);for(int cellNum=0;cellNum<10;cellNum++){Cell cell = row.createCell(cellNum);cell.setCellValue(cellNum);}}System.out.println("over");FileOutputStream fileOutputStream  = new FileOutputStream(PATH+"统计表07大数据类型.xlsx");workbook.write(fileOutputStream);fileOutputStream.close();long end = System.currentTimeMillis();System.out.println((double)(end-begin)/1000);}
}

        缺点:写数据时速度非常慢,非常耗内存,也会发生内存溢出,如100万条。

        优点:可以写较大的数据量,如20万条。

2.2.2.3 07 版本优化
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.junit.Test;import java.io.FileOutputStream;public class ExcelWriteTest {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testWrite07BigDataS() throws Exception {long begin = System.currentTimeMillis();// 1、创建一个工作簿Workbook workbook = new SXSSFWorkbook();// 2、创建一个工作表Sheet sheet = workbook.createSheet();// 3、写入数据for(int rowNum =0;rowNum<100000;rowNum++){Row row = sheet.createRow(rowNum);for(int cellNum=0;cellNum<10;cellNum++){Cell cell = row.createCell(cellNum);cell.setCellValue(cellNum);}}System.out.println("over");FileOutputStream fileOutputStream  = new FileOutputStream(PATH+"统计表07大数据类型优化.xlsx");workbook.write(fileOutputStream);// 清除产生的临时文件((SXSSFWorkbook)workbook).dispose();fileOutputStream.close();long end = System.currentTimeMillis();System.out.println((double)(end-begin)/1000);}
}

        优点:可以写非常大的数据量,如 100万 条甚至更多条,数据速度快,占用更少的内存。

        需要注意的是:代码在过程中会产生临时文件,需要清理临时文件。默认有 100 条记录被保存在内存中,如果超过这数量,则最前面的数据被写入临时文件。如果想自定义内存中数据的数量,可以使用 new SXSSFWorkbook(数量) 。

        SXSSFWorkbook 来至官方的解释:实现 “BigGridDemo” 策略的流式 XSSFWorkbook 版本。这允许写入非常大的文件而不会耗尽内存,因为任何时候只有可配置的行部分被保存在内存中。请注意,仍然可能会消耗大量内存,这些内存基于您正在使用的功能,例如合并区域,注释……仍然只存储在内存中,因此如果广泛使用,可能需要大量内存。

2.3 读取 Excel 操作

2.3.1 03 版本

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.junit.Test;
import java.io.FileInputStream;public class ExcelRead {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testRead03() throws Exception {// 1、获取文件流FileInputStream fileInputStream = new FileInputStream(PATH+"统计表03类型.xls");// 2、创建文件簿,使用 excel 能操作的这边都可以操作Workbook workbook = new HSSFWorkbook(fileInputStream);// 3、得到表Sheet sheet = workbook.getSheetAt(0);// 4、得到行Row row  = sheet.getRow(0);// 5、得到列Cell cell = row.getCell(0);// 读取值的时候需要注意类型,String 和数字调用的方法是不同的。System.out.println(cell.getStringCellValue());fileInputStream.close();}
}

2.3.2 07 版本

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import java.io.FileInputStream;public class ExcelRead {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testRead07() throws Exception {// 1、获取文件流FileInputStream fileInputStream = new FileInputStream(PATH+"统计表07类型.xlsx");// 2、创建文件簿,使用 excel 能操作的这边都可以操作Workbook workbook = new XSSFWorkbook(fileInputStream);// 3、得到表Sheet sheet = workbook.getSheetAt(0);// 4、得到行Row row  = sheet.getRow(0);// 5、得到列Cell cell = row.getCell(1);// 读取值的时候需要注意类型,String 和数字调用的方法是不同的。System.out.println(cell.getStringCellValue());fileInputStream.close();}
}

2.3.3 读取不同类型

        表格的内容如下所示:

        代码如下所示:

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.joda.time.DateTime;
import org.junit.Test;
import java.io.FileInputStream;
import java.util.Date;public class ExcelRead {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testCellType() throws Exception{// 1、获取文件流FileInputStream fileInputStream = new FileInputStream(PATH+"03商品信息.xls");// 2、创建文件簿,使用 excel 能操作的这边都可以操作Workbook workbook = new HSSFWorkbook(fileInputStream);// 3、得到表Sheet sheet = workbook.getSheetAt(0);// 4、获取标题内容Row rowTitle  = sheet.getRow(0);if(rowTitle != null){// 获取列的数量int cellCount = rowTitle.getPhysicalNumberOfCells();for(int cellNum=0;cellNum<cellCount;cellNum++){Cell cell = rowTitle.getCell(cellNum);if(cell != null){// 获取列的类型int cellType = cell.getCellType();// 获取具体的列名String cellValue = cell.getStringCellValue();System.out.print(cellValue+" | ");}}}System.out.println();// 5、获取表中的内容// 获取有多少行的记录int rowCount = sheet.getPhysicalNumberOfRows();for(int rowNum=1;rowNum<rowCount;rowNum++){// 获取第一行数据Row rowData = sheet.getRow(rowNum);if(rowData !=null){// 读取行中的列int cellCount = rowTitle.getPhysicalNumberOfCells();for(int cellNum=0;cellNum<cellCount;cellNum++){System.out.print("["+(rowNum+1)+"-"+(cellNum+1)+"]");Cell cell = rowData.getCell(cellNum);// 匹配类的数据类型if(cell != null){int cellType = cell.getCellType();String cellValue="";switch(cellType){case HSSFCell.CELL_TYPE_STRING:   //字符串System.out.print("【STRING】");cellValue = cell.getStringCellValue();break;case HSSFCell.CELL_TYPE_BOOLEAN:   //布尔System.out.print("【BOOLEAN】");cellValue = String.valueOf(cell.getBooleanCellValue());break;case HSSFCell.CELL_TYPE_BLANK:   //空System.out.print("【BLANK】");break;case HSSFCell.CELL_TYPE_NUMERIC:   //数字(分为日期和普通数字)System.out.print("【NUMERIC】");if(HSSFDateUtil.isCellDateFormatted(cell)){ // 日期System.out.print("【日期】");Date date = cell.getDateCellValue();cellValue = new DateTime(date).toString("yyyy-MM-dd");}else{// 非日期格式,转换成字符串格式System.out.print("【转化为字符串输出】");cell.setCellType(HSSFCell.CELL_TYPE_STRING);cellValue = cell.toString();}break;case HSSFCell.CELL_TYPE_ERROR:   //字符串System.out.print("【数据类型错误】");break;}System.out.println(cellValue);}}}}fileInputStream.close();}
}

2.3.4 读取公式

        操作的表格内容如下所示:

        代码如下所示:

import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.junit.Test;
import java.io.FileInputStream;public class ExcelRead {String PATH ="F:\\idea_home\\poi-excel\\";@Testpublic void testFormula() throws Exception {FileInputStream fileInputStream = new FileInputStream(PATH + "03求和.xls");// 1.创建一个工作簿。使得excel能操作的,这边他也能操作。Workbook workbook = new HSSFWorkbook(fileInputStream);// 2.得到表。Sheet sheet = workbook.getSheetAt(0);Row row = sheet.getRow(6);Cell cell = row.getCell(0);// 拿到计算公司FormulaEvaluator formulaEvaluator = new HSSFFormulaEvaluator((HSSFWorkbook) workbook);// 输出单元格内容int cellType = cell.getCellType();switch (cellType){case Cell.CELL_TYPE_FORMULA:String cellFormula = cell.getCellFormula();System.out.println(cellFormula);// 计算CellValue evaluate = formulaEvaluator.evaluate(cell);String cellValue = evaluate.formatAsString();System.out.println(cellValue);break;}}
}

三、EasyExcel 常用操作

3.1 添加 maven 依赖

    <dependencies><!-- 主要是这个依赖,剩下的依赖都是测试用到的 --><dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>3.0.5</version></dependency><dependency><groupId>lambada</groupId><artifactId>lambada</artifactId><version>1.0.3</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>RELEASE</version><scope>compile</scope></dependency><!--test--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.7</version></dependency></dependencies>

3.2 写操作

        先模拟一个实体类,如下所示:

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;import java.util.Date;@Getter
@Setter
@EqualsAndHashCode
public class DemoData {@ExcelProperty("字符串标题")private String string;@ExcelProperty("日期标题")private Date date;@ExcelProperty("数字标题")private Double doubleData;/*** 忽略这个字段*/@ExcelIgnoreprivate String ignore;
}

        然后写入文档即可,如下所示: 

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.util.ListUtils;
import org.junit.Test;import java.util.Date;
import java.util.List;public class TestWrite {@Testpublic void simpleWrite() {String PATH ="F:\\idea_home\\poi-excel\\easyexcel统计表03类型.xlsx";EasyExcel.write(PATH, DemoData.class).sheet("模板").doWrite(() -> {// 分页查询数据return data();});}private List<DemoData> data() {List<DemoData> list = ListUtils.newArrayList();for (int i = 0; i < 10; i++) {DemoData data = new DemoData();data.setString("字符串" + i);data.setDate(new Date());data.setDoubleData(0.56);list.add(data);}return list;}
}

3.3 读操作

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;import java.util.Date;@Getter
@Setter
@EqualsAndHashCode
public class DemoData {private String string;private Date date;private Double doubleData;
}
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.alibaba.fastjson.JSON;
import org.junit.Test;public class TestRead {@Testpublic void simpleRead() {String PATH ="F:\\idea_home\\poi-excel\\easyexcel统计表03类型.xlsx";// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭// 这里每次会读取3000条数据 然后返回过来 直接调用使用数据就行EasyExcel.read(PATH, DemoData.class, new PageReadListener<DemoData>(dataList -> {for (DemoData demoData : dataList) {System.out.println(JSON.toJSONString(demoData));}})).sheet().doRead();}
}

3.4 更多操作

        详细的文档地址:https://www.yuque.com/easyexcel/doc/easyexcel

相关文章:

POI 和 EasyExcel 操作 Excel

一、概述 目前操作 Excel 比较流行的就是 Apache POI 和阿里巴巴的 easyExcel。 1.1 POI 简介 Apache POI 是用 Java 编写的免费开源的跨平台的 Java API&#xff0c;Apache POI 提供 API 给 Java 程序对 Microsoft Office 格式文档读和写的常用功能。POI 为 “Poor Obfuscati…...

pytorch算力与有效性分析

pytorch Windows中安装深度学习环境参考文档机器环境说明3080机器 Windows11qt_env 满足遥感CS软件分割、目标检测、变化检测的需要gtrs 主要是为了满足遥感监测管理平台&#xff08;BS&#xff09;系统使用的&#xff0c;无深度学习环境内容swin_env 与 qt_env 基本一致od 用于…...

Sublime text启用vim模式

官方教程&#xff1a;https://www.sublimetext.com/docs/vintage.html vintage的github&#xff1a;https://github.com/sublimehq/Vintage...

爬虫进阶-反爬破解6(Nodejs+Puppeteer实现登陆官网+实现滑动验证码全自动识别)

一、NodejsPuppeteer实现登陆官网 1.环境说明 Nodejs——直接从官网下载最新版本&#xff0c;并安装 使用npm安装puppeteer:npm install puppeteer npm install xxx -registry https://registry.npm.taobao.org Chromium会自动下载&#xff0c;前提是网络通畅 2.实践操作…...

【Unity】RenderFeature笔记

【Unity】RenderFeature笔记 RenderFeature是在urp中添加的额外渲染pass&#xff0c;并可以将这个pass插入到渲染列队中的任意位置。内置渲染管线中Graphics 的功能需要在RenderFeature里实现,常见的如DrawMesh和Blit ​ 可以实现的效果包括但不限于 后处理&#xff0c;可以编写…...

golang gin——controller 模型绑定与参数校验

controller 模型绑定与参数校验 gin框架提供了多种方法可以将请求体的内容绑定到对应struct上&#xff0c;并且提供了一些预置的参数校验 绑定方法 根据数据源和类型的不同&#xff0c;gin提供了不同的绑定方法 Bind, shouldBind: 从form表单中去绑定对象BindJSON, shouldB…...

办公技巧:Excel日常高频使用技巧

目录 1. 快速求和&#xff1f;用 “Alt ” 2. 快速选定不连续的单元格 3. 改变数字格式 4. 一键展现所有公式 “CTRL ” 5. 双击实现快速应用函数 6. 快速增加或删除一列 7. 快速调整列宽 8. 双击格式刷 9. 在不同的工作表之间快速切换 10. 用F4锁定单元格 1. 快速求…...

【jvm--方法区】

文章目录 1. 栈、堆、方法区的交互关系2. 方法区的内部结构3. 运行时常量池4. 方法区的演进细节5. 方法区的垃圾回收 1. 栈、堆、方法区的交互关系 方法区的基本理解&#xff1a; 方法区&#xff08;Method Area&#xff09;与 Java 堆一样&#xff0c;是各个线程共享的内存区…...

智慧楼宇3D数据可视化大屏交互展示实现了楼宇能源的高效、智能、精细化管控

智慧园区是指将物联网、大数据、人工智能等技术应用于传统建筑和基础设施&#xff0c;以实现对园区的全面监控、管理和服务的一种建筑形态。通过将园区内设备、设施和系统联网&#xff0c;实现数据的传输、共享和响应&#xff0c;提高园区的管理效率和运营效益&#xff0c;为居…...

算法题:摆动序列(贪心算法解决序列问题)

这道题是一道贪心算法题&#xff0c;如果前两个数是递增&#xff0c;则后面要递减&#xff0c;如果不符合则往后遍历&#xff0c;直到找到符合的。&#xff08;完整题目附在了最后&#xff09; 代码如下&#xff1a; class Solution(object):def wiggleMaxLength(self, nums):…...

接口自动化测试yaml+requests+allure技术,你学会了吗?

前言 接口自动化测试是在软件开发过程中常用的一种测试方式&#xff0c;通过对接口进行自动化测试&#xff0c;可以提高测试效率、降低测试成本。在接口自动化测试中&#xff0c;yaml、requests和allure三种技术经常被使用。 一、什么是接口自动化测试 接口自动化测试是指通…...

android 获取局域网其他设备ip

Android 通过读取本地Arp表获取当前局域网内其他设备信息_手机查看arp-CSDN博客...

angular中使用 ngModel 自定义组件

要创建一个自定义的 Angular 组件&#xff0c;并使用 ngModel 进行双向数据绑定&#xff0c;您可以按照以下步骤操作&#xff1a; 创建自定义组件&#xff1a;首先&#xff0c;使用 Angular CLI 或手动创建一个新的组件。在组件的模板中&#xff0c;添加一个输入元素或其他适合…...

kubernetes pod日志查看用户创建

目录 1.创建用户 1.1证书创建 1.2创建用户 1.3允许用户登陆 1.4切换用户 1.5删除用户 2.RBAC 1.创建用户 1.1证书创建 进入证书目录 # cd /etc/kubernetes/pki创建key # openssl genrsa -out user1.key 2048 Generating RSA private key, 2048 bit long modulus .....…...

HTML5+CSSday4综合案例二——banner效果

bannerCSS展示图&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"viewport" content"wi…...

关于红包雨功能的探索

【高并发优化手段】基于Springboot项目 【红包雨功能的】环境部署&#xff08;弹性伸缩、负载均衡、Redis读写分离、云服务器部署&#xff09; jemeter压测【2万用户每秒5次请求在30秒内处理完请求】 【红包雨压测】提供2万用户30秒内5次请求的并发服务支持 使用工厂模式、策略…...

【已解决】Python打包文件执行报错:ModuleNotFoundError: No module named ‘pymssql‘

【已解决】Python打包文件执行报错&#xff1a;ModuleNotFoundError: No module named pymssql 1、问题2、原因3、解决 1、问题 今天打包一个 tkinter pymssql 的项目的时候&#xff0c;打包过程很顺利&#xff0c;但是打开软件的时候&#xff0c;报错 ModuleNotFoundError: …...

华为云云耀云服务器L实例评测|测试CentOS的网络配置和访问控制

目录 引言 1 理解几个基础概念 2 配置VPC、子网以及路由表 3 配置安全组策略和访问控制规则 3.1 安全组策略和访问控制简介 3.2 配置安全组策略 3.3 安全组的最佳实践 结论 引言 在云计算时代&#xff0c;网络配置和访问控制是确保您的CentOS虚拟机在云环境中安全运行的…...

CSP模拟51联测13 B.狗

CSP模拟51联测13 B.狗 文章目录 CSP模拟51联测13 B.狗题目大意题目描述输入格式输出格式样例样例 1inputoutput 思路 题目大意 题目描述 小G养了很多狗。 小G一共有 n n n\times n nn 条狗&#xff0c;在一个矩阵上。小G想让狗狗交朋友&#xff0c;一条狗狗最多只能交一个…...

GEO生信数据挖掘(七)差异基因分析

上节&#xff0c;我们使用结核病基因数据&#xff0c;做了一个数据预处理的实操案例。例子中结核类型&#xff0c;包括结核&#xff0c;潜隐进展&#xff0c;对照和潜隐&#xff0c;四个类别。本节延续上个数据&#xff0c;进行了差异分析。 差异分析 计算差异指标step12 加载…...

uniapp 对接腾讯云IM群组成员管理(增删改查)

UniApp 实战&#xff1a;腾讯云IM群组成员管理&#xff08;增删改查&#xff09; 一、前言 在社交类App开发中&#xff0c;群组成员管理是核心功能之一。本文将基于UniApp框架&#xff0c;结合腾讯云IM SDK&#xff0c;详细讲解如何实现群组成员的增删改查全流程。 权限校验…...

第19节 Node.js Express 框架

Express 是一个为Node.js设计的web开发框架&#xff0c;它基于nodejs平台。 Express 简介 Express是一个简洁而灵活的node.js Web应用框架, 提供了一系列强大特性帮助你创建各种Web应用&#xff0c;和丰富的HTTP工具。 使用Express可以快速地搭建一个完整功能的网站。 Expre…...

C++实现分布式网络通信框架RPC(3)--rpc调用端

目录 一、前言 二、UserServiceRpc_Stub 三、 CallMethod方法的重写 头文件 实现 四、rpc调用端的调用 实现 五、 google::protobuf::RpcController *controller 头文件 实现 六、总结 一、前言 在前边的文章中&#xff0c;我们已经大致实现了rpc服务端的各项功能代…...

uni-app学习笔记二十二---使用vite.config.js全局导入常用依赖

在前面的练习中&#xff0c;每个页面需要使用ref&#xff0c;onShow等生命周期钩子函数时都需要像下面这样导入 import {onMounted, ref} from "vue" 如果不想每个页面都导入&#xff0c;需要使用node.js命令npm安装unplugin-auto-import npm install unplugin-au…...

转转集团旗下首家二手多品类循环仓店“超级转转”开业

6月9日&#xff0c;国内领先的循环经济企业转转集团旗下首家二手多品类循环仓店“超级转转”正式开业。 转转集团创始人兼CEO黄炜、转转循环时尚发起人朱珠、转转集团COO兼红布林CEO胡伟琨、王府井集团副总裁祝捷等出席了开业剪彩仪式。 据「TMT星球」了解&#xff0c;“超级…...

【2025年】解决Burpsuite抓不到https包的问题

环境&#xff1a;windows11 burpsuite:2025.5 在抓取https网站时&#xff0c;burpsuite抓取不到https数据包&#xff0c;只显示&#xff1a; 解决该问题只需如下三个步骤&#xff1a; 1、浏览器中访问 http://burp 2、下载 CA certificate 证书 3、在设置--隐私与安全--…...

使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台

🎯 使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台 📌 项目背景 随着大语言模型(LLM)的广泛应用,开发者常面临多个挑战: 各大模型(OpenAI、Claude、Gemini、Ollama)接口风格不统一;缺乏一个统一平台进行模型调用与测试;本地模型 Ollama 的集成与前…...

Android第十三次面试总结(四大 组件基础)

Activity生命周期和四大启动模式详解 一、Activity 生命周期 Activity 的生命周期由一系列回调方法组成&#xff0c;用于管理其创建、可见性、焦点和销毁过程。以下是核心方法及其调用时机&#xff1a; ​onCreate()​​ ​调用时机​&#xff1a;Activity 首次创建时调用。​…...

推荐 github 项目:GeminiImageApp(图片生成方向,可以做一定的素材)

推荐 github 项目:GeminiImageApp(图片生成方向&#xff0c;可以做一定的素材) 这个项目能干嘛? 使用 gemini 2.0 的 api 和 google 其他的 api 来做衍生处理 简化和优化了文生图和图生图的行为(我的最主要) 并且有一些目标检测和切割(我用不到) 视频和 imagefx 因为没 a…...

Linux中《基础IO》详细介绍

目录 理解"文件"狭义理解广义理解文件操作的归类认知系统角度文件类别 回顾C文件接口打开文件写文件读文件稍作修改&#xff0c;实现简单cat命令 输出信息到显示器&#xff0c;你有哪些方法stdin & stdout & stderr打开文件的方式 系统⽂件I/O⼀种传递标志位…...