Unable to use XSSF with Excel 2007

巧了我就是萌 提交于 2019-12-11 08:17:59

问题


I am having tough time getting to read data from excel 2007. I am using XSSF to read data from a specific cell of excel but keep getting error -

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions; at org.apache.poi.POIXMLDocumentPart.(POIXMLDocumentPart.java:46)

This is my piece of code:

public static void main(String [] args) throws IOException {
    InputStream ins = new FileInputStream("C:\\Users\\Tarun3Kumar\\Desktop\\test.xlsx"); 
    XSSFWorkbook xwb = new XSSFWorkbook(ins);
    XSSFSheet sheet = xwb.getSheetAt(0);
    Row row = sheet.getRow(1);
    Cell cell = row.getCell(0);
    System.out.println(cell.getStringCellValue());
    System.out.println("a");
}

I have following jars added to build path -

poi-3.6 poi-ooxml-3.6 poi-ooxml-schemas-3.6 x-bean.jar

I could only figure out that setSaveAggressiveNamespaces has replaced setSaveAggresiveNamespaces....


回答1:


there is other issue happen to be: xbean.jar and xmlbeans.jar both have XmlOptions, but only xmlbeans.jar have method you want. I changed path order for xmlbeans.jar first and worked.



来源:https://stackoverflow.com/questions/3031437/unable-to-use-xssf-with-excel-2007

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!