国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Java使用easyExcel導(dǎo)出excel數(shù)據(jù)案例

瀏覽:216日期:2022-05-25 17:49:28

easyExcel簡介:

Java領(lǐng)域解析、生成Excel比較有名的框架有Apache poi、jxl等。但他們都存在一個嚴(yán)重的問題就是非常的耗內(nèi)存。如果你的系統(tǒng)并發(fā)量不大的話可能還行,但是一旦并發(fā)上來后一定會OOM或者JVM頻繁的full gc。easyExcel是阿里巴巴開源的一個excel處理框架,以使用簡單、節(jié)省內(nèi)存著稱。easyExcel采用一行一行的解析模式,并將一行的解析結(jié)果以觀察者的模式通知處理easyExcel能大大減少占用內(nèi)存的主要原因是在解析Excel時沒有將文件數(shù)據(jù)一次性全部加載到內(nèi)存中,而是從磁盤上一行行讀取數(shù)據(jù),逐個解析。

1.導(dǎo)入依賴【poi不能低于3.17,不然可能會報錯】

<dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.17</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.17</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>1.1.2-beta5</version></dependency>

2.控制層

<dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.17</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.17</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>1.1.2-beta5</version></dependency>

3.導(dǎo)出模型

package com.iflytek.edu.hnezxjgl.model;import com.alibaba.excel.annotation.ExcelProperty;import com.alibaba.excel.metadata.BaseRowModel;import lombok.Data;@Datapublic class ExportModel extends BaseRowModel{ /** * 賬號 */ @ExcelProperty(value = {'賬號'}, index = 0) private String platformNum; /** * 姓名 */ @ExcelProperty(value = {'姓名'}, index = 1) private String name; /** * 身份證號 */ @ExcelProperty(value = {'身份證號'}, index = 2) private String idCardNum; /** * 性別 */ @ExcelProperty(value = {'性別'}, index = 3) private String sexName; /** * 年級 */ @ExcelProperty(value = {'年級'}, index = 4) private String gradeName;/** * 班級 */@ExcelProperty(value = {'班級'}, index = 5)private String className; /** * 學(xué)費繳費狀態(tài)名稱 */ @ExcelProperty(value = '學(xué)費繳費狀態(tài)名稱',index = 6) private String studyFeeStatusName; /** * 書本費繳費狀態(tài)名稱 */ @ExcelProperty(value = '書本費繳費狀態(tài)名稱',index = 7) private String bookFeeStatusName; }

4.幾萬條數(shù)據(jù)實現(xiàn)秒導(dǎo)

Java使用easyExcel導(dǎo)出excel數(shù)據(jù)案例

到此這篇關(guān)于Java使用easyExcel導(dǎo)出excel數(shù)據(jù)案例的文章就介紹到這了,更多相關(guān)Java easyExcel導(dǎo)出excel內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: excel
相關(guān)文章:
主站蜘蛛池模板: 江西省| 津市市| 金堂县| 同心县| 涿州市| 汤阴县| 庆云县| 邢台县| 新昌县| 鲁甸县| 惠安县| 修文县| 城口县| 潜江市| 云林县| 唐海县| 宁化县| 二手房| 奎屯市| 明光市| 贵州省| 法库县| 正宁县| 辉南县| 河津市| 哈密市| 大埔区| 磐石市| 衡水市| 德兴市| 西乡县| 五华县| 繁峙县| 茶陵县| 枣阳市| 内丘县| 佳木斯市| 邳州市| 容城县| 綦江县| 金寨县|