EXCEL匯入匯出

2021-08-17 09:39:36 字數 2292 閱讀 3198

// 系統管理員登入,系統下資源管理-分機號列表內容匯出

@suppresswarnings("rawtypes")

@responsebody

public jsonobject selectfenjihaoinxitongforexportbyparam(

@requestparam(value = "fenjihao", required = false) string fenjihao,

@requestparam(value = "userid", required = false) integer userid, // 租戶id

@requestparam(value = "fenpeistate", required = false) integer fenpeistate)

mapparam = new hashmap();

param.put("fenjihao", fenjihao);

param.put("userid", userid);

param.put("fenpeistate", fenpeistate);

//[,]

list> content = iziyuanservice.selectfenjihaoinxitongforexportbyparam(param);

if (content == null || content.size() == 0)

log.info("hashmap型別匯出列表的行數是》:" + content.size());

list> contents = new arraylist>();

// 遍歷,把hashmap變成hashmapfor (hashmap map : content)

contents.add(hashmap);

} log.info("轉換成hashmap型別匯出列表的行數是》:" + contents.size());

string headers = new string ;

string keys = new string ;

// 後台列印

list list = arrays.aslist(headers);

list list2 = arrays.aslist(keys);

"contents是:" + contents);

log.info("headers是:" + list);

log.info("keys是:" + list2);

sxssfworkbook wb = null;

try catch (exception e) finally catch (ioexception e)

} result.put("msg", "success");

result.put("text", "匯出成功!");

result.put("code", 20000);

return result;

}//匯出excel工具類

@component

public class myexport

// 第一步,建立乙個webbook,對應乙個excel檔案

sxssfworkbook xwb = new sxssfworkbook(10000);

// 第二步,在webbook中新增乙個sheet,對應excel檔案中的sheet

sxssfsheet sheet = xwb.createsheet("列表1");

// 第三步,在sheet中新增表頭第0行,注意老版本poi對excel的行數列數有限制short

sxssfrow row = sheet.createrow((int) 0);

// 第四步,建立單元格,並設定值表頭 設定表頭居中

for (int i = 0; i < headers.length; i++)

int currentrownum = 1;

// 向單元格中新增資料

for (int i = 0; i < contents.size(); i++)

}return xwb;

}}

excel匯入匯出

匯出 yii框架中 header content disposition attachment filename 123.xls arr connection createcommand select from recruit queryall array this db get recruit r...

excel匯入匯出

匯出 匯出相對比較簡單在控制層的關鍵 為 string filename 成果資料 dateutils.getdate yyyymmddhhmmss xlsx listpersonneltitlelist personneltitleservice.findlist personneltitle n...

Excel匯入匯出

using system using system.collections.generic using system.data using system.io using system.linq using system.text using system.web using npoi.ss.use...