123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package com.sinosoft.em.evaluate.excel;
- import java.util.List;
- import org.junit.Test;
- import com.quiteJee.poi.excel.utils.ExcelUtils;
- import com.sinosoft.em.evaluate.dto.NormDto;
- import com.sinosoft.em.evaluate.dto.RectificationDto;
- import com.sinosoft.em.evaluate.dto.SpecialDto;
- public class Module2Excel {
- @Test
- public void testObject2Excel() throws Exception {
- String tempPath = "D:/Workspaces/wanggongsi/nwyj/src/应急准备评估标准.xlsx";
- String path = "D:/Workspaces/wanggongsi/nwyj/src/附录A:应急准备评估标准(2017试行版)V2.xlsx";
- // sheet0 导入
- List<NormDto> nlist = ExcelUtils.getInstance().readExcel2Objects(path, 1, 2, NormDto.class, 0);
- // sheet1 导入
- List<SpecialDto> slist = ExcelUtils.getInstance().readExcel2Objects(path, 1, 2, SpecialDto.class, 1);
- // sheet0 导入
- List<RectificationDto> rlist = ExcelUtils.getInstance().readExcel2Objects(path, 1, 2, RectificationDto.class, 2);
-
- // 基于模板导出Excel result.xlsx为最终导出excel
- // 模板中变量说明 $serial_number 生成序列号
- // $data_index 数据起始位置
- // $default_style 数据行样式
- com.quiteJee.poi.excel.utils.ExcelUtils.getInstance().exportObjects2Excel(tempPath, 0, nlist, null, NormDto.class, false, "d:/excel/temp0.xlsx");
- com.quiteJee.poi.excel.utils.ExcelUtils.getInstance().exportObjects2Excel("d:/excel/temp0.xlsx", 1, slist, null,SpecialDto.class, false, "d:/excel/temp1.xlsx");
- com.quiteJee.poi.excel.utils.ExcelUtils.getInstance().exportObjects2Excel("d:/excel/temp1.xlsx", 2, rlist, null,RectificationDto.class, false, "d:/excel/result.xlsx");
-
- }
- public static void main(String[] args) {
- try {
- new Module2Excel().testObject2Excel();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
|