使用easyexcel完成匯出功能

2021-10-11 16:03:21 字數 1419 閱讀 3595

先在pom檔案裡面匯入jar包

<

!--版本號根據你專案而定--

>

com.alibaba<

/groupid>

easyexcel<

/artifactid>

2.2.6

<

/version>

<

/dependency>

2.可以開始寫**邏輯了
(

);// 設定檔名稱

// 這裡urlencoder.encode可以防止中文亂碼 當然和easyexcel沒有關係

string filename = urlencoder.

encode

("測試匯出"

,"utf-8");

response.

setheader

("content-disposition"

,"attachment;filename="

+ filename +

".xlsx");

// sheet名稱

easyexcel.

write

(response.

getoutputstream()

, userbo.

class).

sheet

("測試匯出").

dowrite

(resultbo);}

catch

(exception e)

}3、userpo是返回的實體類

@data

@allargsconstructor

@noargsconstructor

public

class

userpo

4、userbo是匯出excel需要用的實體

@data

@noargsconstructor

@allargsconstructor

@builder

//內容高度

@contentrowheight(25

)//表頭行高度

@headrowheight(25

)//列的寬度

@columnwidth(25

)public

class

userbo

5、直接上輸出結果

使用easyexcel匯出excel檔案

這裡是匯出乙個excel檔案,裡面有兩個sheet 分別是稅賦 表和發票彙總表 controller層 public resultexportexcel string uid,string accountcodelist,date startdate,date enddate,httpservlet...

EasyExcel匯入匯出

註解 匯出 匯出 excel 乙個 sheet,帶表頭 param list 資料 list,每個元素為乙個 baserowmodel param filename 匯出的檔名 param sheetname 匯入檔案的 sheet 名 param model 對映實體類,excel 模型 匯出檔案...

利用easyexcel匯出檔案

1.這裡首先展示一下需要匯出的資料庫資料 2.首先pom檔案引入jar包 com.alibaba easyexcel 2.1.6 3.建立實體類 data public class testexcelinfo select t.name,t.id,t.text from t export info ...