POI 大資料匯出

2021-08-04 00:00:17 字數 722 閱讀 5371

gradle 匯入 org.apache.poi:poi-ooxml:3.14

poi對excel的匯出操作,一般只使用hssfworkbook以及sxssfworkbook:

hssfworkbook用來處理較少的資料量,

sxssfworkbook用來處理超大資料量的匯出,20w資料沒什麼問題。

注意匯出檔案字尾 (.xlsx)

public class excelutils 

int rownum = 1;

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

rownum++;

}output = response.getoutputstream();

response.reset();

response.setcharacterencoding("utf-8");

response.setheader("content-disposition", "attachment;filename="

+ new string(filename.getbytes("gbk"), "iso8859-1")+".xlsx");

workbook.write(output);

} catch (ioexception e) finally

} catch (ioexception e) }}

}

POI 02 Excel大資料匯出

之前提及了 excel 大資料的讀取,現在我們再來了解下 excel 大資料的匯出 官方文件 sxssf streaming usermodel api 生成單個工作表 param rownums 行數 param columnnums 列數 param filepath excel儲存路徑 pub...

POI匯出資料

很簡單的乙個資料匯出啊,因為我的需求只有兩個字段,使用者名稱及手機號所以簡單的一批,記錄一下,方便能對大家有幫助,這個poi也非常的簡單。上 poi 的 jar依賴 org.apache.poi poi3.6 上一下excel工具類 新建 excelutil 類 package com.tianru...

POI匯出資料

workbook wb new hssfworkbook 新建乙個wb工作簿 sheet sheet wb.createsheet 學生的sheet頁 row row sheet.createrow 0 反射獲取屬性名作為表頭 這裡也可以讓別人傳 field fields clz.getdeclar...