改善代码实现逻辑

This commit is contained in:
2018-12-02 14:03:46 +08:00
parent 40a64e6392
commit 26b7123ebc
4 changed files with 359 additions and 392 deletions

View File

@@ -14,7 +14,7 @@ import java.util.Map;
public class ExcelKitTest {
//read excel by fields
@Test
//@Test
public void readTest() throws IOException {
/*String sql1 = "select a, b, c from Sheet1";
String sql2 = "select a, b, c from Sheet1 where a=1 order by b";
@@ -33,7 +33,7 @@ public class ExcelKitTest {
}
//read excel no fields
@Test
//@Test
public void readTest2() throws IOException {
List<Map> list = ExcelKit.readExcel(new File("res/test.xlsx"));

View File

@@ -1,13 +1,10 @@
package com.lxyer.excel;
import org.junit.Test;
import org.redkale.net.http.HttpResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.function.BiFunction;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -25,7 +22,7 @@ import java.util.zip.ZipOutputStream;
public class ExportKitTest {
//1、导出List<javabean>示例
@Test
//@Test
public void exportBean(){
Map<String, String> heads = new LinkedHashMap();
heads.put("姓名", "name");
@@ -52,7 +49,7 @@ public class ExportKitTest {
}
//2、导出List<Map> 示例
@Test
//@Test
public void exportMapToZip(){
Map<String, String> heads = new LinkedHashMap();
@@ -101,6 +98,7 @@ public class ExportKitTest {
* @return
* @throws IOException
*/
/*
public <T> boolean exportExcel(Map head, List<T> rows, HttpServletRequest request, HttpServletResponse response, String xlsName, BiFunction fun) throws IOException {
if(request.getHeader("user-agent") != null && request.getHeader("user-agent").indexOf("MSIE") != -1) {
xlsName = java.net.URLEncoder.encode(xlsName,"utf-8") + ".xls";
@@ -120,6 +118,7 @@ public class ExportKitTest {
os.write(ExcelExportKit.exportExcel(head, rows, fun).toString().getBytes());
return true;
}
*/
/**
* 4、导出压缩的excel示例
@@ -156,6 +155,7 @@ public class ExportKitTest {
* @return
* @throws IOException
*/
/*
public static <T,U,R> void exportExcel(Map head, List<T> rows, HttpResponse response, String xlsName, BiFunction<T,U,R> fun) throws IOException {
xlsName = new String(xlsName.getBytes("utf-8"),"iso-8859-1")+ ".xls";
@@ -165,4 +165,5 @@ public class ExportKitTest {
StringBuilder buf = ExcelExportKit.exportExcel(head, rows, fun);
response.finish(buf.toString().getBytes());
}
*/
}