Commit 3ae44d09 by 刘宇峰

V1.3.0需求开发

1 parent 53183c68
......@@ -17,6 +17,7 @@ import cn.com.glsx.usercenter.api.dto.request.FindUserRequest;
import cn.com.glsx.usercenter.api.feign.UserService;
import com.alibaba.fastjson.JSON;
import com.glsx.plat.core.web.R;
import com.glsx.plat.office.excel.EasyExcelUtils;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.junit.After;
......@@ -27,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
......@@ -214,4 +217,23 @@ public class AdminApplicationTests {
System.out.println(JSON.toJSONString(r.getData()));
}
@Test
public void testExportExcel() throws Exception {
List<String> head = Lists.newArrayList();
List<? extends Object> data = Lists.newArrayList();
testExportExcel(head, data);
}
private void testExportExcel(List<String> head, List data) throws Exception {
OutputStream os = new FileOutputStream("D:\\test.xlsx");
String sheetName = "Sheet1";
List<List<String>> multiHead = Lists.newArrayList();
// 动态添加 表头 headList --> 所有表头行集合
// 第 n 行 的表头
multiHead.add(head);
EasyExcelUtils.writeExcel(os, data, sheetName, multiHead);
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!