抛出java.lang.ClassNotFoundException:org.apache.xmlbeans.XmlException [英] java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException

查看:1710
本文介绍了抛出java.lang.ClassNotFoundException:org.apache.xmlbeans.XmlException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了阅读,我使用Apache POI的 XLSX 文件,我已经下载的zip并放置在以下JSR在我的servlet位置的WebContent / WEB-INF / lib目录并配置构建路径通过蚀

In order to read an xlsx file I'm using apache POI, I've downloaded the zip and placed the following jsrs in my servlet location webcontent/web-inf/lib and configured build path through eclipse

和我的code如下所示,

and my code looks as follows,

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

File uploadedFile = new File(fpath, fileName);
item.write(uploadedFile);
String mimeType = (Files.probeContentType(uploadedFile.toPath())).toString();
System.out.println(mimeType);
if(mimeType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
{
FileInputStream file = new FileInputStream(uploadedFile);
    XSSFWorkbook workbook = new XSSFWorkbook(file);
    for (int i =0; i < workbook.getNumberOfSheets(); i++)
    {
       XSSFSheet sheet = workbook.getSheetAt(i);
       Iterator<Row> row = sheet.iterator();
       while(row.hasNext()) {
   Iterator<Cell> cellIterator = ((Row) row).cellIterator();
       while(cellIterator.hasNext()) {
       Cell cell1 = cellIterator.next();
       switch(cell1.getCellType()) 
         {
    case Cell.CELL_TYPE_BOOLEAN:
    System.out.print(cell1.getBooleanCellValue() + "\n");
    break;
    case Cell.CELL_TYPE_NUMERIC:
    System.out.print(cell1.getNumericCellValue() + "\n");
    break;
    case Cell.CELL_TYPE_STRING:
    System.out.print(cell1.getStringCellValue() + "\n");
    break;
    }
     }

虽然这并不表明和月食的错误它显示了以下错误,当我尝试运行code

Though this does not show and errors on eclipse it shows the following errors when I try to run the code

什么是我的错?如何解决此问题?

What is my mistake? How to solve this?

推荐答案

您需要在 XML豆依赖添加到您的类路径。

You need to add the XML beans dependency to your class path.

该库通常被称为的XMLBeans-x.x.x.jar

这篇关于抛出java.lang.ClassNotFoundException:org.apache.xmlbeans.XmlException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆