poi---Excel导入数据-ClassNotFoundException

1.问题异常:

      Excel导入数据,java采用poi导入,xls格式导入正确,xlsx格式异常,错误信息如下:

1 严重: Servlet.service() for servlet [springMvc] in context with path [/companyCredit] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject] with root cause
2 java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject

问题原因:

        xlsx格式导入,需要增加一个jar包,之后错误信息消失。

2.问题异常:

       java Excel导入,数字太大或太小变成科学计数法问题,解决方法,采用DecimalFormat方案:

 1     for (int j = startcol; j < cellNum; j++) {                //列循环开始
 2                         
 3                         XSSFCell cell = row.getCell(Short.parseShort(j + ""));
 4                         String cellValue = null;
 5                         if (null != cell) {
 6                             switch (cell.getCellType()) {                     // 判断excel单元格内容的格式,并对其进行转换,以便插入数据库
 7                             case 0:
 8                                 DecimalFormat df = new DecimalFormat("0.000");  
 9                                 cellValue = df.format(cell.getNumericCellValue()); 
10 //                                cellValue = String.valueOf(cell.getNumericCellValue());
11                                 break;
12                             case 1:
13                                 cellValue = cell.getStringCellValue();
14                                 break;

3.问题异常:

   jsp中数值不采用科学计数法显示的解决方案:

  jsp页面小数转百分之解决方案:

<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:formatNumber value="1.6286037253000002E7" pattern="#.000"/>
value循环里的变量

小数转百分之解决方案:
<fmt:formatNumber type="percent" value='${var.ratio}'  maxFractionDigits="2"  groupingUsed="false"/>
原文地址:https://www.cnblogs.com/Nico-luo/p/7994663.html