开发者

Unable to use XSSF with Excel 2007

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.se开发者_JAVA技巧tSaveAggressiveNamespaces()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....


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜