- 浏览: 132634 次
- 性别:
- 来自: 重庆
文章分类
最新评论
-
spp_1987:
然后没了?
axis2对应jar的maven配置 -
tmbfe:
有用,谢谢!!
在Eclipse中创建maven项目出现的环境警告 j2se-1.5 -
fuyu_oo:
多谢多谢多谢
在Eclipse中创建maven项目出现的环境警告 j2se-1.5 -
haiou33:
麻烦问下 你这问题解决没 ,我先也出现了这个问题,还没找到合适 ...
axis2 File "/axis2-web/listSingleService.jsp" not found -
sachxp:
感谢PO主,帮了我大忙,特意登录感谢。@xieyongwei ...
在Eclipse中创建maven项目出现的环境警告 j2se-1.5
java 用poi读取excel并区分2003和2007
2003 需要的jar:poi-x.jar
2007 需要的jar:poi-ooxml-x.jar poi-ooxml-schemas-x.jar,dom4j.jar,xmlbeans-2.6.0.jar
如果项目用了maven的话 pom配置中加入以下就可以了:
2003 需要的jar:poi-x.jar
2007 需要的jar:poi-ooxml-x.jar poi-ooxml-schemas-x.jar,dom4j.jar,xmlbeans-2.6.0.jar
如果项目用了maven的话 pom配置中加入以下就可以了:
<properties> <poi-version>3.9</poi-version> </properties> <dependencies> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>${poi-version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>${poi-version}</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>${poi-version}</version> </dependency> <dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> <version>2.6.0</version> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j-core</artifactId> <version>1.4-dev-8</version> </dependency> </dependencies>
package com.jynine.utils; import java.io.File; import java.io.FileInputStream; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * * @author jynine * */ public class ExcelUtil { private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 字符 private static DecimalFormat df = new DecimalFormat("0");// 格式化 number String private static DecimalFormat nf = new DecimalFormat("0.00");// 格式化数字 public static Workbook getWorkbook(File file) throws Exception { String fileName = file.getName(); String extension = fileName.lastIndexOf(".") == -1 ? "" : fileName .substring(fileName.lastIndexOf(".") + 1); FileInputStream fis = new FileInputStream(file); // 根据不同的文件名返回不同类型的WorkBook if (extension.equals("xls")) { return new HSSFWorkbook(fis); } else if (extension.equals("xlsx")) { return new XSSFWorkbook(fis); } else { throw new Exception("不支持该格式的文件!"); } } /** * 读取excel 文件 * @param file * @param startSheet * @param startRow * @return */ public static List<List<Object>> readExcel(File file,int startSheet,int startRow) { List<List<Object>> list = new LinkedList<List<Object>>(); Workbook wb = null; try { wb = getWorkbook(file); Sheet sheet = wb.getSheetAt(startSheet); Object value = null; Row row = null; Cell cell = null; CellStyle cs = null; String csStr = null; Double numval = null; Iterator<Row> rows = sheet.rowIterator(); while (rows.hasNext()) { row = (Row) rows.next(); if(row.getRowNum() >= startRow){ List<Object> cellList = new LinkedList<Object>();; Iterator<Cell> cells = row.cellIterator(); while (cells.hasNext()) { cell = (Cell) cells.next(); switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: cs = cell.getCellStyle(); csStr = cs.getDataFormatString(); numval = cell.getNumericCellValue(); if ("@".equals(csStr)) { value = df.format(numval); } else if ("General".equals(csStr)) { value = nf.format(numval); } else { value = sdf.format(HSSFDateUtil.getJavaDate(numval)); } break; case Cell.CELL_TYPE_STRING: value = cell.getStringCellValue(); break; case Cell.CELL_TYPE_FORMULA: if (!cell.getStringCellValue().equals("")) { value = cell.getStringCellValue(); } else { value = cell.getNumericCellValue() + ""; } break; case Cell.CELL_TYPE_BLANK: value = ""; break; case Cell.CELL_TYPE_BOOLEAN: value = cell.getBooleanCellValue(); break; default: value = cell.toString(); } cellList.add(value); } list.add(cellList); } } } catch (Exception e) { e.printStackTrace(); } return list; } public static void main(String[] args) { File file = new File("D:\\test.xlsx"); List<List<Object>> list = readExcel(file, 0, 0); for (int i = 0; i < list.size(); i++) { List<Object> objects = list.get(i); for (int j = 0; j < objects.size(); j++) { System.out.print(objects.get(j)+"====="); } System.out.println(); } } }
- poi-ooxml-3.9.jar (914.7 KB)
- 下载次数: 5
- dom4j-core-1.4-dev-8.jar (283.1 KB)
- 下载次数: 3
- poi-3.9.jar (1.8 MB)
- 下载次数: 3
- poi-ooxml-schemas-3.9.jar (4.6 MB)
- 下载次数: 6
- xmlbeans-2.6.0.jar (2.6 MB)
- 下载次数: 3
发表评论
-
java.lang.ClassNotFoundException: org.springframework.web.context.request.Reques
2015-01-24 17:11 4040一月 24, 2015 4:51:02 下午 org.apac ... -
解决Spring中@ResponseBody 返回json字符串date类型变成long型的问题
2014-11-14 13:23 8785package com.jynine.service; ... -
java.lang.ClassFormatError: Unknown constant tag 100 in class file java/sql/Driv
2014-08-27 15:34 2248linux下启动tomcat报这个错: Aug 27, 20 ... -
JAVA之jar包读取外面的配置文件和引入其它的jar
2014-03-12 17:32 68641、Java文件 Test.java package co ... -
利用javapns对IOS进行推送
2014-02-21 18:16 2245package com.jynine.javapns; ... -
java之可回调的固定线程池
2013-12-10 18:34 2288import java.util.Map; import j ... -
java之生成图片验证码
2013-12-09 23:42 1643由于自己的项目登录需要验证码,于是便谢了一个图片验证码生成类。 ... -
Axis2实现WebService实例
2013-06-25 00:36 1879Web Service是实现SOA(Service-Orien ... -
java用poi读取excel报错
2013-06-20 20:54 5160java.lang.IllegalStateException ... -
在Eclipse中创建maven项目出现的环境警告 j2se-1.5
2013-06-20 20:25 9865Build path specifies execution ... -
spring配置Quartz定时器时出现的异常
2013-06-17 17:41 2668spring配置Quartz定时器时出现的异常如下: org ... -
java去mybatis里面自动生成的Example文件 和烦人的注释
2013-05-29 23:21 3369上篇mybatis里面写了怎么配置mybatis自动生成代码的 ... -
java数据库连接
2013-05-28 18:35 1098package com.jynine; import j ... -
java写csv文件
2013-05-28 18:29 1784package com.jynine; import j ... -
spring MVC+maven搭建之实例
2013-04-14 12:15 0经过昨天的maven搭建,现在整合maven和sprng mv ... -
java Stringutil 字符串(内含金额转换为中文)
2013-03-18 18:16 1257今天主要写了这个金额转换的方法,这个金额转换最大支持九仟万亿兆 ... -
java中二、八、十 、十六进制之间的转换
2013-03-12 11:43 1063java 中 二、八、十 、十六进制之间的转换 packa ...
相关推荐
本案例中利用Apache Poi读取Excel用法,源码注释详细基本用法!
java poi读取excel 2007 存贮在list中
将excel文件中的内容通过java文件读取出来,包括总行数,列数,单元格内容,合并单元格,行高,列宽,图片等信息。
主要介绍了Java POI读取excel中数值精度损失问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
java读取excel 表格数据。 public static void main(String[] args) { String[][] content=POIExcelUtils.read("E:\\1.xlsx"); for(int i=0;i;i++) { if(content[i]!=null){ for(int j=0;j[i].length;j...
java poi读取excel xls xlsx相关jar包集合,包含: dom4j-1.6.1.jar jsr173_1.0_api.jar poi-3.7-20101029.jar poi-ooxml-3.7-20101029.jar poi-ooxml-schemas-3.7-20101029.jar poi-scratchpad-3.7-20101029.jar ...
java读写Excel,POI.JAR,Word内容读取
java poi读取excel表格数据一整套jar包 包括(dom4j和xmlbeans包)
这个项目实现的功能是读取excel文件中的数据,解析并写入数据库。 读取的excel文件位于项目目录下的 excel\0805.xlsx 使用IntelliJ IDEA开发此项目 使用MYSQL查看数据库 在MYSQL中运行项目db目录下的sql文件,创建...
利用POI读取excel写入到word 利用POI读取excel写入到word 利用POI读取excel写入到word,压缩包里包含了jar包
通过poi读取excel表格信息,可以实现对97,2003,2007,2010等excel表格的读取
Java用poi读取excel文件Java用poi读取excel文件Java用poi读取excel文件
我分享的资源分必须为0!这里面所有读取Excel的poi包都有,虽然版本不是都相同,还有两个必须的,但是不是poi的包,我试过了,没有这两个包,虽然代码可能没错,但是运行会出错。
JAVA IO操作 POI读取excel的内容
Java使用apache POI读取xlsx代码以及相关jar包
Java通过POI读取Excel遍历数据,根本word模板批量生成word文档,demo可运行,可根据需求修改
POI读取excel的例子
Java 操作Excel poi读写excel,所需要的jar包 https://blog.csdn.net/u014646662/article/details/83217382
Java用poi读取excel文件.pdf
压缩包里面有poi相关的jar包,以及我在使用poi时候导入jar包遇到问题总结和一个小demo。