asyExcel导入存在合并单元格的Excel

EasyExcel详解(结合官方文档) EasyExcel的学习分享 阅读详情

Excel表格

下面是Excel表格,成果简介前可以作为主表数据存储(存在合并),成果简介后的数据作为从表数据存储。在这里插入图片描述

实现思路
通过EasyExcel读取Excel数据,用List<AwardsDetailField> list接收
因为POI/EasyExcel对合并单元格的数据只读取一次,需要把为空的单元格也赋值,这是核心技术难点。

循环使用hibernate-validator对数据进行校验
存在校验不通过的数据返回给前端,所有数据校验通过才写入数据库

封装然后写入数据库

用Java8 对List< DetailFeiled> list根据多字段进行分组,得到Map<String,List> map
循环map,封装主表和详细表插入list批量插入
导入时要求同一年数据可以分多次导入,但同一年内,成果名称不允许重复
这个可以在数据库中根据获奖类型+获奖年份+成果名称建立联合约束
ALTER TABLE t_awards ADD CONSTRAINT award_type_year_product UNIQUE (award_type,award_year,award_product);
 

相关代码

下面贴出的是通过EasyExcel读取Excel数据的测试代码

pom依赖:

<dependencies>
   <dependency>
       <groupId>com.alibaba</groupId>
       <artifactId>easyexcel</artifactId>
       <version>2.2.6</version>
   </dependency>
   <dependency>
       <groupId>com.alibaba</groupId>
       <artifactId>fastjson</artifactId>
       <version>1.2.76</version>
   </dependency>
   <!--lombok-->
   <dependency>
       <groupId>org.projectlombok</groupId>
       <artifactId>lombok</artifactId>
       <version>1.18.20</version>
       <scope>provided</scope>
   </dependency>
   <!--junit测试-->
   <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.12</version>
       <scope>test</scope>
   </dependency>
   <!--slf4j简单实现-->
   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <version>1.7.25</version>
       <scope>compile</scope>
   </dependency>
</dependencies>
AwardsDetailField类:

package com.importexcel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;

/**
 * Excel对应的Java实体类
 */
@Data
public class AwardsDetailField {

    @ExcelProperty(value="奖项等级(一级分类)",index = 0)
    private String topClass;

    @ExcelProperty(value="奖项等级(二级分类)",index = 1)
    private String secondClass;

    @ExcelProperty(value="获奖年份",index = 2)
    private String awardYear;

    @ExcelProperty(value="获奖产品/成果名称",index = 3)
    private String awardProduct;

    @ExcelProper

easyexcel导入合并单元格解析(纵向合并,横向合并都支持) 阅读详情

相关推荐

工具篇-EasyExcel-web行列合并导入

本文介绍excel 存在行列合并项的数据,进行web导入。根据自身业务完成定义@ExcelProperty(value = "序号") private Integer rowNum;@ExcelProperty(value = "指标类型") private String dictType;@ExcelProperty(value = "指标所属航道") private String channel;

拽着尾巴的鱼儿的博客 1466

Ruoyi框架使用easyExcel实现单元格合并

/ 你也可以在创建行的时候进行拦截,也可以在创建单元格的时候拦截,不同功能实现不同的接口 public class TableHeadHandler implements SheetWriteHandler {// 基础的excel操作,可以在此处添加表头的样式 Workbook workbook = writeWorkbookHolder . getWorkbook();row0 . createCell(0) . setCellValue("第一行");

wuhuangji的博客 6391

【密码学】生成8位26个字母和数字的全排列(密码字典,密钥)c++代码(非递归高效直接)

生成8位26个字母和数字的全排列(密钥)代码(非递归高效直接) 用C语言或C++,生成一个8位的26个字母和数字的全排列的原代码,例如从:00000000到ZZZZZZZZ。 说明:生成的这个字典会非常大,有36^8条记录,估计要3T的硬盘,跑一个晚上看看         这个方法比递归更高效,更直接。                                                ...

Wu_Being 的CSDN 博客 1万+

【通信协议学习】关于Xmodem、Ymodem、Zmodem、ASCII、Binary传输协议

不同传输协议简介 Xmodem YModem YModem分成YModem-1K与YModem-g。 YModem的数据格式如下: Binary Ascii 不同传输协议简介 串行通信的文件传输协议主要和常用的有:Xmodem、Ymodem、Zmodem以及KERMIT、Ymodem-G、ASCII等。 ASCII:这是最快的传输协议,但只能传送文本文件。 Xmodem:这种古老的传输协议速度较慢,但由于使用了CRC错误侦测方法,传输的准确率可高达99.6%。 Ymodem:这是X..

冯宇的博客 1万+

企业多部门网络隔离实战:用华为交换机VLAN+Trunk实现行政/技术部安全隔离

本文详细介绍了如何利用华为交换机的VLAN划分与Trunk链路技术,实现企业行政与技术部门间的网络逻辑隔离。通过具体的配置案例,阐述了Access与Trunk端口的工作原理、单交换机与多交换机环境下的部署策略,并延伸至三层网关部署与ACL访问控制,为企业构建安全、高效的核心网络提供实战指导。

p4q5r6s7t的博客 585

ESP32、MicroPython、天问ASR-PRO,串口发送数据并播报

天问ASRPRO语音芯片内置脑神经网络处理器,支持DNN、TDNN、RNN等神经网络及卷积运算硬件运算,非软件运算,支持语音识别、声纹识别、语音增强、语音检测、单麦克风降噪增强、单麦克风回声消除、360度全方位拾音等功能。ASR-PRO可以图形化编程,降低开发难度,对小白友好。之前使用ASRPRO与ESP32进行过语音控制,这次由于一个项目需要对ESP处理过后的数据进行播报,就想到利用该模块。以下程序主要为测试代码,并非实际项目,仅供参考学习(若有错误,欢迎指正)。二者通过串口通信,波特率为9600。

weak_student的博客 5959

CMU开源NavRL:深度强化学习如何破解无人机动态避障难题?

卡内基梅隆大学(CMU)开源了NavRL框架,利用深度强化学习解决无人机在复杂环境中的动态避障难题。该框架通过创新的状态表示、多目标奖励函数设计以及独立的安全屏障机制,使无人机能够通过仿真训练自主学会灵活、安全的导航策略,并成功实现从仿真到真实环境的零样本迁移。

hope8的博客 726

VScode+MPLAB AI助手:Microchip MCU开发全流程实战解析

本文详细解析了如何使用VScode搭配MPLAB AI助手进行Microchip MCU开发的完整流程。从环境配置、工程创建到代码生成与调试,全面介绍了AI助手在提升开发效率、优化代码和故障排除方面的实际应用,为嵌入式开发者提供了一套高效的开发解决方案。

hh234的博客 1151

一文读懂5G网络整体架构(接入网+承载网+核心网)

接入网重构分级(分工更细、效率更高)、承载网三段化升级(管道更宽、更智能)、核心网服务化云化(管理更灵活、成本更低)最终实现“成本最优、资源灵活、场景适配”,才能支撑自动驾驶、工业互联网、智慧城市、VR/AR等各种新场景,真正走进我们的生活。

鲸落寰宇 442

【3天快速入门WPF】1-从最简单的xaml开始

首先我们要知道xaml语法中声明即定义,意思就是“见到元素就相当于创建实例”,MainWindow.xaml的主干是一个元素里包含着一个 元素。这段程序就是在定义一个Window类的实例,这个实例的一个组成部分是一个Grid类的实例。

Zy100Papa的博客 1632

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: 电商秒杀实战代码
Ztw_bb
博客等级 码龄5年 0粉丝 13原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值