feat:模块名称调整
This commit is contained in:
34
springboot-poi/pom.xml
Normal file
34
springboot-poi/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.0.18</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.tiesheng.poi.pojos;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
public interface PoiReadBase {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tiesheng.poi.pojos;
|
||||
|
||||
import com.alibaba.excel.annotation.write.style.*;
|
||||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
||||
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@HeadRowHeight(24)
|
||||
@HeadFontStyle(fontHeightInPoints = 13)
|
||||
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT)
|
||||
@ContentRowHeight(20)
|
||||
@ContentFontStyle(fontHeightInPoints = 12)
|
||||
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
|
||||
@ColumnWidth(20)
|
||||
public interface PoiWriteBase {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.tiesheng.poi.util;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.tiesheng.poi.pojos.PoiReadBase;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PoiReadUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 读取文件
|
||||
*
|
||||
* @param file
|
||||
* @param readListener
|
||||
* @return
|
||||
*/
|
||||
public static <T extends PoiReadBase> void read(File file, Class<T> tClass, ReadListener<T> readListener) {
|
||||
EasyExcel.read(file, tClass, readListener).autoTrim(true).headRowNumber(1).sheet().doRead();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.tiesheng.poi.util;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.annotation.write.style.*;
|
||||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
||||
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hao
|
||||
*/
|
||||
@HeadRowHeight(24)
|
||||
@HeadFontStyle(fontHeightInPoints = 13)
|
||||
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT)
|
||||
@ContentRowHeight(20)
|
||||
@ContentFontStyle(fontHeightInPoints = 12)
|
||||
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
|
||||
@ColumnWidth(20)
|
||||
public class PoiWriteUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static <T extends PoiWriteBase> boolean export(List<T> list, Class<T> tClass, String absPath, String sheetName) {
|
||||
EasyExcel.write(absPath, tClass).excelType(ExcelTypeEnum.XLSX)
|
||||
.sheet(sheetName)
|
||||
.doWrite(list);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user