excel控件只爲簡單寫入數據表--github找到ExcelUtil筆記

github地址

https://github.com/SargerasWang/ExcelUtil

文檔地址

https://sargeraswang.com/blog/2018/11/27/excelutil-1-dot-2-1-doc/

本文只記錄個人使用–寫入excel

1、導入maven依賴

<dependency>
    <groupId>com.sargeraswang.util</groupId>
    <artifactId>excel-util</artifactId>
    <version>1.2.1</version>
</dependency>

官網1.2.4在maven中央倉庫好像沒有

2、準備實體類

public class Propmanger {

    private String proOrgCode;

    private String cityOrgCode;

    @ExcelCell(index = 0)
    private String provinceName;

    @ExcelCell(index = 1)
    private String cityName;

    //setter and getter 省略...
}

3、到出邏輯

	    List<Propmanger> propmangers = propertyMangerService.seleceAll();
        System.out.println(propmangers.size());
        Map<String,String> map = new LinkedHashMap<>();
        map.put("provinceName","省");
        map.put("cityName","市");
        File f=new File("test.xls");
        OutputStream out =new FileOutputStream(f);

        ExcelUtil.exportExcel(map, propmangers, out);
        out.close();

4、結果

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章