Подтвердить что ты не робот

Java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException

Чтобы прочитать файл xlsx, я использую apache POI, я загрузил zip и разместил следующие jsrs в моем местоположении сервлета webcontent/web-inf/lib и настроил путь сборки через eclipse

enter image description here

и мой код выглядит следующим образом:

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

Хотя это не отображается, и ошибки в eclipse показывают следующие ошибки при попытке запустить код

enter image description here

В чем моя ошибка? Как это решить?

4b9b3361

Ответ 1

Вам нужно добавить зависимость XML beans к вашему пути к классу.

Библиотека обычно называется xmlbeans-x.x.x.jar

Ответ 2

Добавьте xmlbeans-xpath.jar в свои библиотеки.

Ответ 3

Я загрузил последние бинарные файлы poi-3.17, а xmlbeans-x.x.x.jar включен в сам загруженный пакет.

Прикрепленные скриншоты FYR.

Первичные банки, необходимые для xlsx xmlbeans-x.x.x.jar в папке ooxml-lib