EasyExce简单使用案例

EasyExcel给指定单元格加样式(CellWriteHandler版) 上面这几行代码很好从网上找到但是我在实际使用时我的项目中使用了EasyExcel的同时还用到了EasyPoi导致数据丢失、代码不起效果等功能。由于 EasyExcel与EasyPoi都是对poi的封装,我个人感觉是他俩底层用的poi版本不一致才导致了问题的出现。这其实只是一种方法,另一种是去掉EasyExcel,EasyPoi中的poi依赖单独引入poi依赖。 阅读详情

EasyExce简单使用案例
Easyexcel针对导出的订单进行合并

案例

1、处理表格重新生成新的表格

需求:产品给的数据,需要将参数给绑定到一个链接上,数据量较多,写个demo处理

文档:传送门

映射表格的实体Model

@Data
public class BookModel {

    @ExcelProperty(index = 0,value = "书籍id")
    String bookId;

    @ExcelProperty(index = 1,value = "书籍名")
    String title;

    @ExcelProperty(index = 2,value = "书源id")
    String bookSourceId;

    @ExcelProperty(index = 3,value = "XXX链接")
    String directHapLink;

    @ExcelProperty(index = 4,value = "XXX链接")
    String directHttpLink;

    @ExcelProperty(index = 5,value = "XXX链接")
    String directMonitorLink;

    @ExcelProperty(index = 6,value = "XXX链接")
    String unionHapLink;

    @ExcelProperty(index = 7,value = "XXX链接")
    String unionHttpLink;

    @ExcelProperty(index = 8,value = "XXX链接")
    String unionMonitorLink;

}

直接写个Demo跑数据,由于涉及到查询数据库,所以还需要用@SpringBootTest

@SpringBootTest
public class SpliceStringTest {
    @Autowired
    private BookDao bookDao;

    @Test
    void test() throws FileNotFoundException {

        File file = new File("/Users/xxx/Downloads/old.xlsx");
        File quickApp = new File("/Users/xxx/Downloads/new.xlsx");
        EasyExcel.read(new FileInputStream(file), BookModel.class, new AnalysisEventListener<BookModel>(){

            private List<BookModel>bookModels=new ArrayList<>();

            @Override
            public void invoke(BookModel data, AnalysisContext context) {

                Long bookId = Long.valueOf(data.getBookId());
                String title="";
                if(bookId!=null){
                    BookEntity bookEntity = bookDao.findById(bookId).get();
                    data.setBookSourceId(bookEntity.getSource().getId().toString());
                }
                // format
                String directHapLink=String.format("hap://xxx?book=%s&source=%s&title=%s"
                ,data.getBookId(),data.getBookSourceId(),data.getTitle());
                data.setDirectHapLink(directHapLink);

                String directHttpLink=String.format("https://xxx?book=%s&source=%s&title=%s",
                       data.getBookId(),data.getBookSourceId(),data.getTitle());
                data.setDirectHttpLink(directHttpLink);

                String directMonitorLink=String.format("https://xxx?book=%s",
                        data.getBookId());
                data.setDirectMonitorLink(directMonitorLink);

                String unionHapLink=String.format("hap://xxx?book=%s&source=%s&title=%s",
                        data.getBookId(),data.getBookSourceId(),data.getTitle());
                data.setUnionHapLink(unionHapLink);

                String unionHttpLink=String.format("https://xxx?book=%s&source=%s&title=%s",
                        data.getBookId(),data.getBookSourceId(),data.getTitle());
                data.setUnionHttpLink(unionHttpLink);

                String unionMonitorLink=String.format("https://xxx?book=%s",
                       data.getBookId() );
                data.setUnionMonitorLink(unionMonitorLink);


                bookModels.add(data);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                save();
            }

            private void save() {
                EasyExcel.write(quickApp,BookModel.class).sheet().doWrite(bookModels);
            }
        }).sheet().doRead();


    }
}

针对上个案例对表格进行优化样式

上面表格样式太难看了,链接也没有设置单元格为链接。

映射单元格实体
@Data
@ContentRowHeight(value = 90)//设置 row 高度,不包含表头标记在 类上
@HeadRowHeight(100)//设置表头高度(与 @ContentRowHeight 相反)标记在类上
public class BookModel {

    @ExcelProperty(value = "类型")
    @ColumnWidth(value = 10)
    @ContentStyle(horizontalAlignment= HorizontalAlignmentEnum.CENTER,verticalAlignment= VerticalAlignmentEnum.CENTER)
    String type;

    @ExcelProperty(value = "书籍id")
    @ColumnWidth(value = 30)
    @ContentStyle(horizontalAlignment= HorizontalAlignmentEnum.CENTER,verticalAlignment= VerticalAlignmentEnum.CENTER)
    String bookId;

    @ExcelProperty(value = "书籍名")
    @ColumnWidth(value = 30)
    @ContentStyle(horizontalAlignment= HorizontalAlignmentEnum.CENTER,verticalAlignment= VerticalAlignmentEnum.CENTER)
    String title;

    @ExcelProperty(value = "作者")
    @ColumnWidth(value = 20)
    @ContentStyle(horizontalAlignment= HorizontalAlignmentEnum.CENTER,verticalAlignment= VerticalAlignmentEnum.CENTER)
    String author;

    @ExcelProperty(value = "书源id")
    @ColumnWidth(value = 20)
    @ContentStyle(horizontalAlignment= HorizontalAlignmentEnum.CENTER,verticalAlignment= VerticalAlignmentEnum.CENTER)
    String bookSourceId;

    @ContentStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND,
            fillForegroundColor=12,horizontalAlignment = HorizontalAlignmentEnum.DISTRIBUTED,
            verticalAlignment = VerticalAlignmentEnum.CENTER)
    @ExcelProperty(value = "直投hap链接")
    @ColumnWidth(50)
    String directHapLink;

    @ExcelProperty(value = "直投http链接")
    @ColumnWidth(50)
    @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.DISTRIBUTED,
            verticalAlignment = VerticalAlignmentEnum.CENTER)
    String directHttpLink;

    @ExcelProperty(value = "直投监测链接")
    @ColumnWidth(40)
    @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.DISTRIBUTED,
            verticalAlignment = VerticalAlignmentEnum.CENTER)
    String directMonitorLink;

    @ExcelProperty(value = "联盟hap链接")
    @ColumnWidth(40)
    @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.DISTRIBUTED,
            verticalAlignment = VerticalAlignmentEnum.CENTER)
    String unionHapLink;

    @ExcelProperty(value = "联盟http链接")
    @ColumnWidth(40)
    @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.DISTRIBUTED,
            verticalAlignment = VerticalAlignmentEnum.CENTER)
    String unionHttpLink;

    @ExcelProperty(value = "联盟监测链接")
    @ColumnWidth(40)
    @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.DISTRIBUTED,
            verticalAlignment = VerticalAlignmentEnum.CENTER)
    String unionMonitorLink;

    @ExcelProperty("测试数字")
    @ContentStyle(dataFormat = 2)
    Double testNumber;

}

1、对单元格进行了水品和垂直居中
2、对链接进行了设置单元格为链接,点击内容即可跳转到响应地址
3、由于链接内容过长,比较难看设置对齐方式为自动换行并且设置行高来适应数据
4、对于最后一行数字进行设置保留两位

注册一个写表格添加链接的handler
public class LinkWriteHandler implements CellWriteHandler {

    // 添加超链接的列下标
    List<Integer>linkColumnIndex;

    //从第几行开始添加 0 代表标题行
    int mergeRowIndex;


    public LinkWriteHandler(List<Integer> linkColumnIndex, int mergeRowIndex) {
        this.linkColumnIndex = linkColumnIndex;
        this.mergeRowIndex = mergeRowIndex;
    }

    @Override
    public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {
        CellWriteHandler.super.beforeCellCreate(writeSheetHolder, writeTableHolder, row, head, columnIndex, relativeRowIndex, isHead);
    }

    @Override
    public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
        CellWriteHandler.super.afterCellCreate(writeSheetHolder, writeTableHolder, cell, head, relativeRowIndex, isHead);
    }

    @Override
    public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, WriteCellData<?> cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
        CellWriteHandler.super.afterCellDataConverted(writeSheetHolder, writeTableHolder, cellData, cell, head, relativeRowIndex, isHead);
    }

    @Override
    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
        int curRowIndex = cell.getRowIndex();
        int curColumnIndex = cell.getColumnIndex();

        if(curRowIndex>=mergeRowIndex && linkColumnIndex.contains(curColumnIndex)){
            addLinkCell(writeSheetHolder,cell,curRowIndex,curColumnIndex);
        }


    }


    private void addLinkCell(WriteSheetHolder writeSheetHolder,Cell cell, int curRowIndex, int curColumnIndex) {
        String cellStringValue=cell.getCellType()== CellType.STRING?cell.getStringCellValue():null;
        if(StringUtils.isNotBlank(cellStringValue)){
            try {
                Sheet sheet = writeSheetHolder.getSheet();
                CreationHelper creationHelper = sheet.getWorkbook().getCreationHelper();
                Hyperlink hyperlink = creationHelper.createHyperlink(HyperlinkType.URL);
                hyperlink.setAddress(cellStringValue);
                cell.setHyperlink(hyperlink);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }


}
读取表格保存数据处理写表格
public class EasyExcelTest {

    File oldFile = new File("/Users/xxx/Downloads/xxx1.xlsx");
    File newFile = new File("/Users/xxx/Downloads/xxx2.xlsx");


    @Test
    public void test(){
        EasyExcel.read(oldFile, BookModel.class, new AnalysisEventListener<BookModel>() {

            List<BookModel>saveList=new ArrayList<>();
            @Override
            public void invoke(BookModel data, AnalysisContext context) {
                data.setTestNumber(RandomUtils.nextDouble(1.0,100.0));
                saveList.add(data);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                changeNewExcel(saveList);
            }

            private void changeNewExcel(List<BookModel> saveList) {
                EasyExcel.write(newFile,BookModel.class)
                        .registerWriteHandler(new LinkWriteHandler(ListUtils.newArrayList(5,6,7,9,10),1))
                        .sheet("xxx")
                        .doWrite(saveList);
            }
        }).sheet().doRead();
    }

}

使用Eaexcel踩坑合集

1、实体定义采用驼峰命名不然可能获取的值为空

基于Apache MINA SSHD配置及应用 Apache MINA SSHD是一个基于Java的开源SSH服务器/客户端实现,支持SSH2协议,提供文件传输、shell访问等功能。该代码实现了一个SftpClientService服务类,封装了SFTP文件操作,包括读取文件(readOnce/readLines)和写入文件(writeOnce)等核心功能。通过SftpProperties配置类管理连接参数,并采用Builder模式创建SSH会话。主要特点包括:支持大文件分块传输、自动创建目录、严格的异常处理和... 阅读详情

相关推荐

STM32串口DMA双缓冲机制实战:提升数据传输效率的终极方案

本文深入解析了STM32串口DMA双缓冲机制的核心原理与实战配置。通过对比传统中断方式,阐述了双缓冲如何实现数据接收与处理的“无缝接力”,从而在工业传感器数据采集等高负载场景下,将CPU占用率降至极低水平并彻底避免数据丢失。文章提供了基于标准外设库的详细配置步骤、中断处理逻辑及性能实测数据,是提升嵌入式系统串口通信效率和可靠性的终极方案。

weixin_29192365的博客 89

Easy-Excel简单使用

但他们都存在一个严重的问题就是非常的耗内存,poi有一套SAX模式的API可以一定程度的解决一些内存溢出的问题,但内存消耗依然很大。easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析依然需要100M左右内存,改用easyexcel可以降低到几M,并且再大的excel也不会出现内存溢出。@NumberFormat 数据格式转换 如:@NumberFormat(value = “#.##%”) 0.3947 -> 39.47%

qq_53519086的博客 650

通过EMIF接口实现FPGA与DSP的高速连接(方法)

请注意,具体的连接细节和步骤可能会根据所使用的FPGA和DSP型号以及特定的应用需求而有所不同。开发DSP和FPGA上的软件,以实现数据交换和处理。根据系统的具体需求,对FPGA和DSP的接口逻辑进行优化,以减少延迟、提高数据吞吐量或降低资源消耗。它通常支持多种类型的存储器,如SRAM、DRAM、ROM等,以及通过特定的接口与FPGA连接。对于FPGA,需要编程来实现与DSP的接口逻辑,包括地址译码、数据传输、时序控制等。在连接完成后,进行详细的调试和测试,以确保数据能够在DSP和FPGA之间正确传输。

AigcFox的博客 4603

easyexcel读取excel将数据存到mysql【一个简单的例子】

读取excel。

lh155136的博客 2787

Flash芯片的VCC上电到可操作时间过长

Flash的VCC上电到操作时间(tVSL)通常有最大值限制,如果超过这个时间,核心风险是状态机不同步和指令锁存错误。比如芯片内部振荡器可能已经尝试启动又休眠了,但主控却在这之后才发送指令,导致完全 misinterpreted。Flash芯片的(从电源上电到可以正常进行读写操作的时间)如果过长,会产生一系列负面影响简单来说,这个时间过长意味着电源上升速度太慢,违反了芯片的要求。

qq_61918649的博客 734

CAN 比特率和采样点计算

架构根据输入频率和比特率自动计算。

ldinvicible的专栏 798

Easy Excel从入门到精通!!!

一篇文章一万八千字带你玩转Easy Excel !!!

m0_65450831的博客 3168

【100%通过率】华为OD机试真题 Python 实现【网上商城优惠活动 / 模拟商场优惠打折II】

某网上商场举办优惠活动,发布了满减、打折、无门槛3种 优惠券,分别为: 1:每满100元优惠10元,无使用数限制,如100~199元可以使用1张减10元,200~299可使用2张减20元,以此类推; 2:92折券,1次限使用1张,如100元,则优惠后为92元, 3:无门槛5元优惠券,无使用数限制,直接减5元。

MISAYAONE的博客 9383

Easy Excel使用

Easy Excel

jar_home的博客 793

2、实时DSP编程技术及其应用

本文详细介绍了实时数字信号处理(DSP)技术及其应用,涵盖三种流行的浮点DSP处理器系列的特点、开发工具和优化方法。通过具体的应用实例,如语音压缩、音乐信号处理和雷达信号处理,展示了如何在实际项目中应用这些技术,帮助工程师提高系统的性能和可靠性。

cicd6pipeline的博客 847

使用EasyExce对excel进行读取

EasyExcel EasyExcel是阿里开源的一个excel处理框架,以使用简单、节省内存著称,其能大大减少内存占用的原因是因为在解析Excel的时候,并没有把excel文件中所有的内容都一次性全部加载到内存中,而是从文件中一行一行进行读取,逐个解析。 Java领域中,excel处理的比较有名的框架主要是poi和jxl,但这两个都存在内存占用非常大的问题,如果系统的并发量不大的话基本没有什么问题,但是如果并发使用量特别大的话,极容易造成OOM问题。 EasyExcel读取文件采用一行一行读取,数据读取

whhwch1986的博客 2337

Cesium 实战 28 - 三维视频融合(视频投影)

Cesium 实战 27 - 三维视频融合(视频投影)。

非科班Java出身GISer的博客 3389

使用EasyExce实现Excel文件解析

使用easyexcel技术如何读取excel中的数据呢

累计发表博客60余万字,CSDN 博客专家、Java 领域优质创作者、华为云享专家、阿里云专家博主。专注分享 Java 优质文章,毕设实战项目开发,全网粉丝10W+ 2077

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

easyexce复杂表头导出(二)

easyexce复杂表头导出(二) 导出结果: 思路: 步骤: 1.引入依赖 <!-- easyexcel --> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>2.2.0-beta1</version> </dependency>

时间煮酒 2929

深度学习工具包 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")

easyexce复杂表头导出(一)

easyexce复杂表头导出(一) 公司最近需要使用easyexcel通过后端来完成复杂表头的导出,最近玩了下感觉还可以,整理了一个demo供参考 步骤 1.引入所需依赖 <!-- easyexcel --> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <ve

时间煮酒 2746

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

EasyExce复杂场景应用(动态合并标题,填充导出联合使用)

EasyExce复杂场景应用(动态合并标题,填充导出联合使用)EasyExcel是一个基于Java的简单、省内存的读写Excel的开源项目。在尽可能节约内存的情况下支持读写百M的Excel。 github地址: https://github.com/alibaba/easyexcel官方文档: https://www.yuque.com/easyexcel/doc/easyexcelB站视频: https://www.bilibili.com/video/BV1Ff4y1U7Qc代码如下(示例): 2.组装

JavaSwx的博客 1460

EasyExce表头自适应列宽

EasyExcel表头自适应列宽 // 导出 EasyExcelFactory .write(response.getOutputStream(), VoucherListVO.class) .registerWriteHandler(new AdaptiveColumnWidthStrategy()) .sheet() .doWrite(voucherListVOList); // 自适应表头列宽策略 public class Adapti

qq_41901039的博客 3574

easyexce时区国际化处理

LocalDateTime 解析器。

codeSmart的博客 566

EasyExce导出合并单元格

CustomMergeStrategy.ava,通用适配代码,直接复制使用。

MrZ120的博客 409

Excel神办公—【一】使用EasyExce实现数据“有对象写入”和“无对象写入”

写在前面 最近在做项目开发的时候,有用到easy excel技术来解析和写入excel,所以今天在这里和大家分享一下如何使用easy excel技术来解析excel文件的操作 Easyexcel技术介绍 Easyexcel技术是在poi的基础上发展起来的,它是对poi’的优化和提升,相对于poi来说,Easyexcel的好处就是在对文件读写的时候,是一行一行的读取的,这样做的好处就是在数据存储到数据库的时候,可以很好的避免内存消耗,占用较多的CPU资源。而且相对于poi,easyexcel的操作更加便捷,同

累计发表博客60余万字,CSDN 博客专家、Java 领域优质创作者、华为云享专家、阿里云专家博主。专注分享 Java 优质文章,毕设实战项目开发,全网粉丝10W+ 3276

java easyExce 动态表头列数不固定

在开发中,可能会碰到多个客户提供不同格式的表单,导致表头不固定。例如,客户上传的 Excel 数据可能包含不同的字段,这些字段会动态变化,此时我们需要一个灵活的处理方案。下面是一个简单的 UML 序列图,展示了生成 Excel 的流程。下面是一个使用 EasyExcel 导出动态表头的简单示例。

mcband的博客 477

Alibaba/EasyExce踩坑 Can not find ‘Converter‘ support class ZoneDateTime

报错:alibaba.excel.exception.ExcelDataConvertException: Can not find ‘Converter‘ support class ZoneDateTime 主要原因是 Converter接口的convertToExcelData没有对 ZoneDateTime的时间类型进行转换。需要手动转换一下。 导出Excel文件的需要在实体类属性上添加@ExcelProperty注解,当实体类属性存在 ZonedDateTime 的类型时,会导出失败。 添加一个Z

个人下雪的博客 2582

easyExce模板填充生成Excel的实际操作,多sheet页处理

easyExce模板变量填充生成Excel,以及多sheet页模板处理

huqiankunlol的博客 8060

easyexce报表导入导出(代码版)

easyexce报表导入导出 无模板导入 @GetMapping("/upload") public StandardResult getUserRole(@RequestParam(value = "file", required = true) MultipartFile file){ try { if (null==file){ return StandardResult.faild("参数错误!");

qq_37945621的博客 295

EasyExce 自定义类型转换器,Converter<String[]>

EasyExce 自定义类型转换器,Converter

weixin_49238911的博客 506
上一篇: springsecurity注入PasswordEncoder导致循环引用
下一篇: mysql中inner join 和left join 使用
Nuyoahll-_-ll
博客等级 码龄8年 170粉丝 189原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值