快速學習POI 自定義工具類

2021-10-01 19:44:16 字數 2599 閱讀 5608

(1)自定義註解

@retention(retentionpolicy.runtime)

@target(elementtype.field)

public @inte***ce excelattribute

(2)匯出工具類

@getter

@setter

public

class

excelexportutil

/*** 基於註解匯出

}}

(3)匯入工具類

public

class

excelimportutil

/*** 基於註解讀取excel

*/public list

readexcel

(inputstream is,

int rowindex,

int cellindex)}}

} list.

add(entity);}

}catch

(exception e)

return list;

}/**

* 型別轉換 將cell 單元格格式轉為 字段型別

* */

private object covertattrtype

(field field, cell cell)

throws exception

elseif(

"date"

.equals

(fieldtype)

)elseif(

"int"

.equals

(fieldtype)

||"integer"

.equals

(fieldtype)

)elseif(

"double"

.equals

(fieldtype)

||"double"

.equals

(fieldtype)

)else

}/**

* 格式轉為string

* @param cell

* @return

*/public string getvalue

(cell cell)

switch

(cell.

getcelltype()

)else

// 去除 浮點型 自動加的 .0

if(strcell.

endswith

(".0"))

return strcell;

}case boolean:

return string.

valueof

(cell.

getbooleancellvalue()

);default

:return"";

}}}

(1)匯入資料

list

list =

newexcelimportutil

(user.

class).

readexcel

(is,1,

2);

(2)匯出資料

(value =

"/export/"

, method = requestmethod.get)

public

void

export

(@pathvariable

(name =

"month"

) string month)

throws exception

自定義工具類01

ftputil ftpclient 工具類 idutils 生成一切id 的策略的工具類。可以使用他生成名稱 jsonutils 物件與json 格式轉換的工具類 public class ftputil 切換到上傳目錄if ftp.changeworkingdirectory basepath f...

JDBC 自定義工具類 實現登入

一 配置檔案 jdbc1.properties url 本地資料庫位址 user 資料庫的賬號 password 資料庫的密碼 driver 註冊位址 url jdbc mysql localhost 3306 db1?servertimezone gmt 2b8user root password...

(sandbar dll)C 自定義工具條

td.sandbar.menubar menubar td.sandbar.sandbarmanager sandbarmanager td.sandbar.container topsandbardock td.sandbar.view private void form1 load object...