diff --git a/pom.xml b/pom.xml index 6bb84af..f53e193 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.lxyer + net.tccn excel 0.1.1 jar @@ -40,8 +40,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + 14 + 14 diff --git a/src/net/tccn/kit/poi/ExcelKit.java b/src/net/tccn/kit/poi/ExcelKit.java index 817fb50..0071495 100644 --- a/src/net/tccn/kit/poi/ExcelKit.java +++ b/src/net/tccn/kit/poi/ExcelKit.java @@ -51,7 +51,7 @@ public class ExcelKit { * @date 2015-6-16 下午5:56:56 */ //map:data,sheetName,hds,hdNames, - public static Workbook exportExcels(List> list) { + public static Workbook exportExcels(List list) { Workbook wb = new SXSSFWorkbook(); //创建工作薄 for (int i = 0; i < list.size(); i++) { diff --git a/test/com/lxyer/excel/ExcelKitTest.java b/test/net/tccn/excel/test/ExcelKitTest.java similarity index 93% rename from test/com/lxyer/excel/ExcelKitTest.java rename to test/net/tccn/excel/test/ExcelKitTest.java index 8077781..1b35036 100644 --- a/test/com/lxyer/excel/ExcelKitTest.java +++ b/test/net/tccn/excel/test/ExcelKitTest.java @@ -1,10 +1,13 @@ -package com.lxyer.excel; +package net.tccn.excel.test; import net.tccn.kit.poi.ExcelKit; import org.apache.poi.ss.usermodel.Workbook; import org.junit.Test; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; import java.util.*; import static java.util.Arrays.asList; @@ -15,7 +18,7 @@ import static java.util.Arrays.asList; public class ExcelKitTest { @Test - public void mapExport(){ + public void mapExport() { // 数据List T可以是map,也可以是某个Javabean Map m1 = new HashMap(); m1.put("name", "张三"); @@ -57,14 +60,14 @@ public class ExcelKitTest { System.out.println(sql1.substring(0,sql1.indexOf("from")).replace("select", "").replace(" ", "")); */ - String[] fields ={"name", "age"}; + String[] fields = {"name", "age"}; File file = new File("target/abx.xls"); List list = ExcelKit.readExcel(file, fields); System.out.println("list.size: " + list.size()); - list.forEach(x->{ - x.forEach((k,v)->{ + list.forEach(x -> { + x.forEach((k, v) -> { System.out.print(String.format("%s:%s \t", k, v)); }); System.out.println(); @@ -77,8 +80,8 @@ public class ExcelKitTest { // 在不传 String[] fields 会把值从左到右分别赋值给 a...z,这样的key上 List list = ExcelKit.readExcel(new File("target/abx.xls")); - list.forEach(x->{ - x.forEach((k,v)->{ + list.forEach(x -> { + x.forEach((k, v) -> { System.out.print(String.format("%s:%s \t", k, v)); }); System.out.println(); @@ -88,6 +91,7 @@ public class ExcelKitTest { //--------------------------- 通用导入案例 -------------------------------- static Properties properties = new Properties(); + static { try { // 读取导入配置文件 @@ -99,6 +103,7 @@ public class ExcelKitTest { /** * 构建入库语句 + * * @param list 数据list * @param heads 数据库需要入库的字段 * @param table 实体表 diff --git a/test/com/lxyer/excel/ExportKitTest.java b/test/net/tccn/excel/test/ExportKitTest.java similarity index 94% rename from test/com/lxyer/excel/ExportKitTest.java rename to test/net/tccn/excel/test/ExportKitTest.java index 4855510..078da85 100644 --- a/test/com/lxyer/excel/ExportKitTest.java +++ b/test/net/tccn/excel/test/ExportKitTest.java @@ -1,11 +1,12 @@ -package com.lxyer.excel; +package net.tccn.excel.test; import net.tccn.kit.poi.ExcelExportKit; -import net.tccn.kit.poi.ExcelKit; -import org.apache.poi.ss.usermodel.Workbook; import org.junit.Test; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.lang.reflect.Field; import java.util.*; import java.util.function.BiFunction; @@ -13,23 +14,21 @@ import java.util.function.Function; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import static java.util.Arrays.asList; - /** - * 以下均为非poi导出使用示例 + * 以下均为非poi导出使用示例 * 1、导出List示例 * 2、导出List 示例 * 3、javax.servlet web项目中开发使用示例 * 4、导出压缩的excel示例 * 5、redkale web项目导出示例 - * + * * Created by liangxianyou at 2018/7/6 10:29. */ public class ExportKitTest { //1、导出List示例 //@Test - public void exportBean(){ + public void exportBean() { Map heads = new LinkedHashMap(); heads.put("姓名", "name"); heads.put("年龄", "age"); @@ -56,7 +55,7 @@ public class ExportKitTest { //2、导出List 示例 //@Test - public void exportMapToZip(){ + public void exportMapToZip() { Map heads = new LinkedHashMap(); heads.put("姓名", "name"); @@ -128,6 +127,7 @@ public class ExportKitTest { /** * 4、导出压缩的excel示例 + * * @param head * @param rows * @param file @@ -135,12 +135,12 @@ public class ExportKitTest { * @param * @throws IOException */ - public void exportExcelZip(Map head, List rows, File file, BiFunction fun) throws IOException { + public void exportExcelZip(Map head, List rows, File file, BiFunction fun) throws IOException { ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file)); BufferedOutputStream bos = new BufferedOutputStream(zos); - ZipEntry zipEntry = new ZipEntry(file.getName().split("[.]")[0]+".xls"); + ZipEntry zipEntry = new ZipEntry(file.getName().split("[.]")[0] + ".xls"); zos.putNextEntry(zipEntry); StringBuilder buf = ExcelExportKit.exportExcel(head, rows, fun); @@ -153,6 +153,7 @@ public class ExportKitTest { /** * 5、redkale web项目导出示例 + * * @return * @throws IOException */ @@ -167,7 +168,6 @@ public class ExportKitTest { response.finish(buf.toString().getBytes()); } */ - @Test public void t() { Object t = new Person(); @@ -227,6 +227,7 @@ public class ExportKitTest { /** * 对象属性处理, + * * @param o * @param function * @auther lxyer diff --git a/test/com/lxyer/excel/Person.java b/test/net/tccn/excel/test/Person.java similarity index 96% rename from test/com/lxyer/excel/Person.java rename to test/net/tccn/excel/test/Person.java index bd3edd7..1a23504 100644 --- a/test/com/lxyer/excel/Person.java +++ b/test/net/tccn/excel/test/Person.java @@ -1,4 +1,4 @@ -package com.lxyer.excel; +package net.tccn.excel.test; import java.util.Date;
* Created by liangxianyou at 2018/7/6 10:29. */ public class ExportKitTest { //1、导出List示例 //@Test - public void exportBean(){ + public void exportBean() { Map heads = new LinkedHashMap(); heads.put("姓名", "name"); heads.put("年龄", "age"); @@ -56,7 +55,7 @@ public class ExportKitTest { //2、导出List 示例 //@Test - public void exportMapToZip(){ + public void exportMapToZip() { Map heads = new LinkedHashMap(); heads.put("姓名", "name"); @@ -128,6 +127,7 @@ public class ExportKitTest { /** * 4、导出压缩的excel示例 + * * @param head * @param rows * @param file @@ -135,12 +135,12 @@ public class ExportKitTest { * @param * @throws IOException */ - public void exportExcelZip(Map head, List rows, File file, BiFunction fun) throws IOException { + public void exportExcelZip(Map head, List rows, File file, BiFunction fun) throws IOException { ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file)); BufferedOutputStream bos = new BufferedOutputStream(zos); - ZipEntry zipEntry = new ZipEntry(file.getName().split("[.]")[0]+".xls"); + ZipEntry zipEntry = new ZipEntry(file.getName().split("[.]")[0] + ".xls"); zos.putNextEntry(zipEntry); StringBuilder buf = ExcelExportKit.exportExcel(head, rows, fun); @@ -153,6 +153,7 @@ public class ExportKitTest { /** * 5、redkale web项目导出示例 + * * @return * @throws IOException */ @@ -167,7 +168,6 @@ public class ExportKitTest { response.finish(buf.toString().getBytes()); } */ - @Test public void t() { Object t = new Person(); @@ -227,6 +227,7 @@ public class ExportKitTest { /** * 对象属性处理, + * * @param o * @param function * @auther lxyer diff --git a/test/com/lxyer/excel/Person.java b/test/net/tccn/excel/test/Person.java similarity index 96% rename from test/com/lxyer/excel/Person.java rename to test/net/tccn/excel/test/Person.java index bd3edd7..1a23504 100644 --- a/test/com/lxyer/excel/Person.java +++ b/test/net/tccn/excel/test/Person.java @@ -1,4 +1,4 @@ -package com.lxyer.excel; +package net.tccn.excel.test; import java.util.Date;