poi和easyexcel性能区别

poi

xls(03) 65536 poi HSSF
xlsx(07) 无限制 poi-ooxml XSSF

工作簿:Workbook
工作表:Sheet
行:Row
列:Cell

poi写:03和07

@Testpublic void testWrite03() throws IOException {Workbook workbook = new HSSFWorkbook();Sheet sheet = workbook.createSheet("03表限制65536");for (int i = 0; i < 10; i++) {Row row = sheet.createRow(i);for (int j = 0; j < 10; j++) {Cell cell = row.createCell(j);cell.setCellValue(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));}}FileOutputStream outputStream = new FileOutputStream(PATH + "03表限制65536.xls");workbook.write(outputStream);outputStream.close();}
 @Testpublic void testWrite07() throws IOException {Workbook workbook = new HSSFWorkbook();Sheet sheet = workbook.createSheet("07表无限制");for (int i = 0; i < 10; i++) {Row row = sheet.createRow(i);for (int j = 0; j < 10; j++) {Cell cell = row.createCell(j);cell.setCellValue(i + j);}}FileOutputStream outputStream = new FileOutputStream(PATH + "07表无限制.xlsx");workbook.write(outputStream);outputStream.close();}


 /*** 2.99* @throws IOException*/@Testpublic void testWrite03BigData() throws IOException {long begin = System.currentTimeMillis();Workbook workbook = new HSSFWorkbook();Sheet sheet = workbook.createSheet("03插入大量数据");for (int i = 0; i < 65536; i++) {Row row = sheet.createRow(i);for (int j = 0; j < 10; j++) {Cell cell = row.createCell(j);cell.setCellValue(j);}}FileOutputStream fileOutputStream = new FileOutputStream(PATH + "03插入大量数据.xls");workbook.write(fileOutputStream);fileOutputStream.close();long end = System.currentTimeMillis();System.out.println((double) (end - begin) / 1000);}/*** 10.78(65536)* 15.70(100000)* @throws IOException*/@Testpublic void testWrite07BigData() throws IOException {long begin = System.currentTimeMillis();Workbook workbook = new XSSFWorkbook();Sheet sheet = workbook.createSheet("07插入大量数据");for (int i = 0; i < 100000; i++) {Row row = sheet.createRow(i);for (int j = 0; j < 10; j++) {Cell cell = row.createCell(j);cell.setCellValue(j);}}FileOutputStream fileOutputStream = new FileOutputStream(PATH + "07插入大量数据.xlsx");workbook.write(fileOutputStream);fileOutputStream.close();long end = System.currentTimeMillis();System.out.println((double) (end - begin) / 1000);}/*** 4.26(100000)* 需要清楚零时文件* @throws IOException*/@Testpublic void testWrite07BigDataS() throws IOException {long begin = System.currentTimeMillis();Workbook workbook = new SXSSFWorkbook();Sheet sheet = workbook.createSheet("07插入大量数据S");for (int i = 0; i < 100000; i++) {Row row = sheet.createRow(i);for (int j = 0; j < 10; j++) {Cell cell = row.createCell(j);cell.setCellValue(j);}}FileOutputStream fileOutputStream = new FileOutputStream(PATH + "07插入大量数据S.xlsx");workbook.write(fileOutputStream);fileOutputStream.close();long end = System.currentTimeMillis();//清楚零时文件((SXSSFWorkbook) workbook).dispose();System.out.println((double) (end - begin) / 1000);}

错误:java.lang.noclassdeffounderror:
org/apache/poi/ss/usermodel/date1904support

解决:poi版本选择:一致

<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>

poi读:03和07

 @Testpublic void testRead03() throws IOException {FileInputStream fileInputStream = new FileInputStream(PATH + "03表限制65536.xls");Workbook workbook = new HSSFWorkbook(fileInputStream);Sheet sheet = workbook.getSheetAt(0);Row row = sheet.getRow(0);Cell cell = row.getCell(0);System.out.println(cell.getStringCellValue());fileInputStream.close();}@Testpublic void testRead07() throws IOException {FileInputStream fileInputStream = new FileInputStream(PATH + "07插入大量数据.xlsx");Workbook workbook = new XSSFWorkbook(fileInputStream);Sheet sheet = workbook.getSheetAt(0);Row row = sheet.getRow(0);Cell cell = row.getCell(0);System.out.println(cell.getNumericCellValue());fileInputStream.close();}

poi读取问题:后缀名修改实际上可能没改变文件属性,要实际看看是什么类型的看表格有没有大于65535
大于65535.xslx用XSSF

**注意:**读取单元格要注意不同类型选择

/*** 读取excel工具类* @param fileInputStream 文件输入流* @throws IOException*/public void readExcelUtil(FileInputStream fileInputStream) throws IOException {Workbook workbook = new XSSFWorkbook(fileInputStream);Sheet sheet = workbook.getSheetAt(0);//获取表头内容Row rowTitle = sheet.getRow(0);if (rowTitle != null) {int cellCount = rowTitle.getPhysicalNumberOfCells();for (int cellNum = 0; cellNum < cellCount; cellNum++) {Cell cell = rowTitle.getCell(cellNum);if (cell != null) {//                    int cellType = cell.getCellType();String cellValue = cell.getStringCellValue();System.out.print(cellValue + "|");}}System.out.println();}//获取表格数据int rowCount = sheet.getPhysicalNumberOfRows();for (int rowNum = 1; rowNum < rowCount; rowNum++) {Row rowData = sheet.getRow(rowNum);if (rowData != null) {int cellCount = rowTitle.getPhysicalNumberOfCells();for (int cellNum = 0; cellNum < cellCount; cellNum++) {Cell cell = rowData.getCell(cellNum);String cellValue = "";if (cell != null) {switch (cell.getCellTypeEnum()) {case STRING:System.out.print("STRING ");cellValue = cell.getStringCellValue();break;case BOOLEAN:System.out.print("BOOLEAN ");cellValue = String.valueOf(cell.getBooleanCellValue());break;case BLANK:System.out.print("BLANK ");break;case NUMERIC:if (HSSFDateUtil.isCellDateFormatted(cell)) {System.out.print("日期 ");Date date = cell.getDateCellValue();cellValue = new DateTime(date).toString("yyyy/MM/dd");} else {//防止数字过长,先转化为stringSystem.out.print("数字过长,先转化为string ");cell.setCellType(CellType.STRING);cellValue = cell.toString();}break;case ERROR:System.out.print("ERROR ");break;case FORMULA:System.out.print("FORMULA ");String formula = cell.getCellFormula();System.out.print(formula);FormulaEvaluator formulaEvaluator = new HSSFFormulaEvaluator((HSSFWorkbook) workbook);CellValue evaluate = formulaEvaluator.evaluate(cell);cellValue = evaluate.formatAsString();}System.out.println(cellValue);}}}}fileInputStream.close();}

easyexcel

https://www.yuque.com/easyexcel

java处理excel(poi和easyexcel)相关推荐

  1. Java操作excel(POI、EasyExcel)

    Apache POI和EasyExcel学习 easyExcel easyExcel 官网地址:https://www.yuque.com/easyexcel/doc/easyexcel EasyEx ...

  2. java导出excel组件alibaba easyexcel和apache poi性能对比

    java导出excel组件alibaba easyexcel和apache poi性能对比 背景: 开发中出现web页面导出记录到excel导致服务oom奔溃,代码中使用apache poi组件导出, ...

  3. Java操作Excel报表,EasyExcel用法大全

    一:EasyExcel简介 1.EasyExcel是一个基于Java的简单.省内存的读写Excel的开源项目.在尽可能节约内存的情况下支持读写百M的Excel. 2.Java解析.生成Excel比较有 ...

  4. JAVA操作Excel之阿里巴巴EasyExcel

    EasyExcel JAVA解析Excel工具 POI非常耗内存,会出现内存溢出 以下是EasyExcel和POI解析Excel的对比图 导入依赖 <dependency><grou ...

  5. java excel api 下载文件_Java-Excel Java操作Excel POI(Jakarta POI API) - 下载 - 搜珍网

    Java操作Excel/Jakarta POI API/data/Jakarta POI API.doc Java操作Excel/Jakarta POI API/jar/poi-3.0.2-FINAL ...

  6. java导出Excel(POI模式 Ajax下载 Post传参) bootstrap table getVisibleColumns获取显示的列

    工具类 (正式使用) package com.qyj.utils;import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson. ...

  7. Java处理Excel文件工具包-easyexcel使用详解

    https://github.com/alibaba/easyexcel 由于项目需要对大量Excel数据进行输入输出处理,在使用JXL,POI后发现很容易出现OOM,最后在网上找到阿里的开源项目Ea ...

  8. Java操作Excel导入导出(EasyExcel)

    在管理一个系统时,总会有许多的数据,为了方便浏览查看数据,系统总会提供「导出Excel」的功能:有导出就有导入,在要向数据库中插入大量的数据时,我们向程序提供准备好的 Excel,然后程序读取表格内容 ...

  9. java处理Excel表格(EasyExcel)

    1.EasyExcel特点 Java领域解析.生成Excel比较有名的框架有Apache poi.jxl等.但他们都存在一个严重的问题就是非常的耗内存.如果你的系统并发量不大的话可能还行,但是一旦并发 ...

  10. java Export Excel POI 转

    最终选择用POI成功导出excel.总之很有用. http://www.cnblogs.com/xwdreamer/archive/2011/07/20/2296975.html http://poi ...

最新文章

  1. puppet 类、模块
  2. java jvm崩溃_IObjects java 代码导致jvm崩溃了
  3. centos7 go yum 安装_超详细的centos7下载安装Postgresql11(yum安装)教程
  4. C++11智能指针shared_ptr、weak_ptr、unique_ptr用法
  5. empt注意事项 php_PHP编程注意事项
  6. Linux基础(文件权限续篇)
  7. python编辑器_自学python第一课之下载安装编辑器
  8. 或许是 Nginx 上配置 HTTP2 最实在的教程了
  9. asp和php漏洞,ASP_实例分析ASP上传漏洞入侵实战及扩展,【上传漏洞欺骗技术】 - phpStudy...
  10. 该不该和教师一起去做项目
  11. arm低功耗模式种类
  12. ASUS华硕天选/天选2P/天选3P/飞行堡垒789/枪神/枪神2/枪神3/枪神4/枪神5P/枪神6P/幻14 FA506 FX506安装原厂Windows10系统原装Windows11出厂系统重装
  13. 温哥华菜鸟生活攻略(1)
  14. HTTP、HTTPS
  15. 委以重用的意思_刘表为什么不对刘备委以重用?
  16. linux虚拟机安装过程中卡在mount: block device /dev/sr0 is write-protected, mounting read-only
  17. 裸金属架构和寄居架构的特点与区别
  18. Windows编程-判断一个程序是64还是32位的小程序
  19. java 面试题总结
  20. 2018年“铲屎官”研究报告    -- 男人不如狗,宠物市场了解一下

热门文章

  1. Spark 算子之交集、并集、差集
  2. 利用其它站接口向飞信好友单/群发信息(不支持https)
  3. linux内核配置大全
  4. 浏览器内核与js引擎
  5. 2.3 树的同构(树,c)
  6. 《一个陌生女人的来信》茨威格
  7. Android查看手机位置,安卓能不能查找iphone?安卓手机查iphone位置的方法
  8. 首席新媒体运营商学院创始人黎想:活动运营推广,如何策划核心玩法
  9. 爆品分析第5期 | 一条视频带货3700+,这款斋月不锈钢厨具套装火了!
  10. python的tkinter做界面连接MySQL(上)