|
|
@ -1,6 +1,5 @@ |
|
|
|
package com.alibaba.easyexcel.test.temp; |
|
|
|
package com.alibaba.easyexcel.test.temp; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -10,12 +9,12 @@ import org.junit.Ignore; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.easyexcel.test.demo.fill.FillData; |
|
|
|
import com.alibaba.easyexcel.test.demo.fill.FillData; |
|
|
|
|
|
|
|
import com.alibaba.easyexcel.test.temp.fill.FillData2; |
|
|
|
import com.alibaba.easyexcel.test.util.TestFileUtil; |
|
|
|
import com.alibaba.easyexcel.test.util.TestFileUtil; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig; |
|
|
|
import com.alibaba.excel.write.metadata.fill.FillConfig; |
|
|
|
import com.alibaba.excel.write.style.row.SimpleRowHeightStyleStrategy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 写的填充写法 |
|
|
|
* 写的填充写法 |
|
|
@ -46,7 +45,7 @@ public class FillTempTest { |
|
|
|
// 如果数据量大 list不是最后一行 参照下一个
|
|
|
|
// 如果数据量大 list不是最后一行 参照下一个
|
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); |
|
|
|
excelWriter.fill(data(), fillConfig, writeSheet); |
|
|
|
excelWriter.fill(data(), fillConfig, writeSheet); |
|
|
|
excelWriter.fill(data(), fillConfig, writeSheet); |
|
|
|
// excelWriter.fill(data2(), fillConfig, writeSheet);
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
map.put("date", "2019年10月9日13:28:28"); |
|
|
|
map.put("date", "2019年10月9日13:28:28"); |
|
|
|
map.put("total", 1000); |
|
|
|
map.put("total", 1000); |
|
|
@ -73,7 +72,7 @@ public class FillTempTest { |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
// 直接写入数据
|
|
|
|
// 直接写入数据
|
|
|
|
excelWriter.fill(data(), writeSheet); |
|
|
|
excelWriter.fill(data(), writeSheet); |
|
|
|
excelWriter.fill(data(), writeSheet); |
|
|
|
excelWriter.fill(data2(), writeSheet); |
|
|
|
|
|
|
|
|
|
|
|
// 写入list之前的数据
|
|
|
|
// 写入list之前的数据
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
@ -97,6 +96,16 @@ public class FillTempTest { |
|
|
|
// 新建一个 然后一点点复制过来的方案,最后导致list需要新增行的时候,后面的列的数据没法后移,后续会继续想想解决方案
|
|
|
|
// 新建一个 然后一点点复制过来的方案,最后导致list需要新增行的时候,后面的列的数据没法后移,后续会继续想想解决方案
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<FillData2> data2() { |
|
|
|
|
|
|
|
List<FillData2> list = new ArrayList<FillData2>(); |
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
|
|
|
|
FillData2 fillData = new FillData2(); |
|
|
|
|
|
|
|
list.add(fillData); |
|
|
|
|
|
|
|
fillData.setTest("ttttttt" + i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<FillData> data() { |
|
|
|
private List<FillData> data() { |
|
|
|
List<FillData> list = new ArrayList<FillData>(); |
|
|
|
List<FillData> list = new ArrayList<FillData>(); |
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|