EasyExcel读取Excel并返回Excel行内容、生成并写入Excel内容、字符串提取图片url地址、java 8 分组、过滤、去重

EasyExcel涉及使用内容

1、EasyExcel读取Excel并返回Excel行内容;

2、EasyExcel生成并写入Excel内容;

3、字符串提取图片url地址;

4、java 8 分组、过滤、去重

实体对象类:

 

ProductDetailTestDTO.java

package com.spj.test.manager.service.productimg;

import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @author shipj
 * @version 1.0
 * @Title: ProductImgDTO
 * @Description: TODO
 * @date 2021-04-19 17:28
 */
@Data
public class ProductDetailTestDTO implements Serializable {
    @ExcelProperty(value = "product_detail")
    private String productDetail;
}

 

ProductPictureTestDTO.java

package com.spj.test.manager.service.productimg;

import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @author shipj
 * @version 1.0
 * @Title: ProductImgDTO
 * @Description: TODO
 * @date 2021-04-19 17:28
 */
@Data
public class ProductPictureTestDTO implements Serializable {
    @ExcelProperty(value = "picture_url")
    private String pictureUrl;
}

 

ProductSkuTestDTO.java

package com.spj.test.manager.service.productimg;

import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @author shipj
 * @version 1.0
 * @Title: ProductSkuTestDTO
 * @Description: TODO
 * @date 2021-04-20 11:04
 */
@Data
public class ProductSkuTestDTO implements Serializable {
    @ExcelProperty("sku_picture_url")
    private String skuPictureUrl;
}

 

测试类

IProductPcturesDealServiceTest.java

package com.spj.test.manager.service;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.spj.test..manager.service.productimg.ProductDetailTestDTO;
import com.spj.test.manager.service.productimg.ProductPictureTestDTO;
import com.spj.test.manager.service.productimg.ProductSkuTestDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @Author shipj
 * &

你可能感兴趣的:(excel,EasyExcel,java)