25.easyexcel簡単な書き込み操作


に頼る

		<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>2.1.6</version>
        </dependency>

エンティティークラス

@Data
public class ExcelData
{
    @ExcelProperty(" ")
    private String id;
    @ExcelProperty(" ")
    private String name;
}

テスト

@Test
    public void testExcel()
    {
        ExcelWriterBuilder writer = EasyExcel.write("d:\\2.xls",ExcelData.class);
        ExcelWriterSheetBuilder sheet = writer.sheet("gunsmoke");
        ArrayList<ExcelData> dataList = new ArrayList<>();
        for(int index = 0; index < 10; index++)
        {
            ExcelData tempData = new ExcelData();
            tempData.setId(String.valueOf(index));
            tempData.setName("name" + String.valueOf(index));
            dataList.add(tempData);
        }
        sheet.doWrite(dataList);
    }