Hi,

Sounds like you are using an incorrect version of the XMLBeans library.
Make sure that version 3.1.0 is available and no other version is included
in the classpath.

Dominik.

On Mon, May 13, 2019 at 2:43 PM Dieter <dieter.edin...@web.de> wrote:

> Hello,
> I downloaded poi-bin-4.1.0 and added all jar files including the ones in
> the
> lib folder to my project.
> The code works for xls files, but with xlsx files the following error
> occurs:
>
> Caused by: java.lang.NoSuchMethodError:
>
> org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
>         at
> org.apache.poi.ooxml.POIXMLTypeLoader.<clinit>(POIXMLTypeLoader.java:43)
>         at
> org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86)
>         ... 27 more
>
> Coding sample:
>
> import java.io.*;
> import java.math.BigDecimal;
> import java.util.*;
>
> import org.apache.poi.ss.usermodel.*; // POI 4.x
> import org.apache.poi.hssf.usermodel.HSSFWorkbook;
> import org.apache.poi.poifs.filesystem.POIFSFileSystem;
> import org.apache.poi.xssf.usermodel.XSSFWorkbook;
>
>         public void execute() throws Exception {
>                 String[][] data = new String[1000][1000];
>                 FileInputStream fis;
>                         try {
>                                 fis = new
> FileInputStream(Filename.toString());
>                         } catch (FileNotFoundException e) {
>                                 e.printStackTrace();
>                                 return;
>                         }
>                         Workbook wb = null;
>
>                         try {
>                           if
> (Filename.toString().toLowerCase().endsWith(".xls")) {
>                             wb = new HSSFWorkbook(new
> POIFSFileSystem(fis)); // *.xls
>                           } else if
> (Filename.toString().toLowerCase().endsWith(".xlsx")) {
>                                 wb = new XSSFWorkbook(fis); // *.xlsx
>                           }
>                         } catch (IOException e) {
>                                 e.printStackTrace();
>                                 return;
>                         }
>
>                         Sheet sheet = wb.getSheetAt(0); // Get Excel Sheet
>                         // Iterate through each row.
>                         Iterator rows = sheet.rowIterator();
>                         while (rows.hasNext()) {
>                                 Row row = (Row) rows.next();
>                                 Iterator cells = row.cellIterator();
>                                 while (cells.hasNext()) {
>                                         Cell cell = (Cell) cells.next();
>                                         String vCellValue =
> cell.toString();
>                                         data[ row.getRowNum() ][
> cell.getColumnIndex() ] = vCellValue;
>                                 }
>                         }
>         }
>
>
>
>
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@poi.apache.org
> For additional commands, e-mail: user-h...@poi.apache.org
>
>

Reply via email to