package cn.com.qmth.examcloud.tool;

import cn.com.qmth.examcloud.tool.utils.ExcelHelper;
import com.alibaba.excel.EasyExcel;
import com.google.common.collect.Lists;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class DataTest {

    @Test
    public void demo() throws Exception {
        String dataFilePath = "C:/Users/deason/Desktop/ddd.xlsx";

        List<List<String>> excelRows = new ArrayList<>();
        for (int i = 1; i <= 100; i++) {
            long index = 1000000000L + i;

            List<String> data = new ArrayList<>();
            data.add("考生_" + i);
            data.add(String.valueOf(index));
            data.add(String.valueOf(index));
            data.add("org101");
            data.add("c101");
            excelRows.add(data);
        }

        List<String> excelHeaders = Lists.newArrayList("姓名", "学号", "身份证号", "机构代码", "课程代码");
        EasyExcel.write(dataFilePath)
                .head(ExcelHelper.buildHeaders(excelHeaders))
                .registerWriteHandler(ExcelHelper.sheetStrategy())
                .sheet()
                .doWrite(excelRows);
    }

}
