无法在 Excel 2007 中使用 XSSF [英] Unable to use XSSF with Excel 2007

查看:27
本文介绍了无法在 Excel 2007 中使用 XSSF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难从 excel 2007 中读取数据.我正在使用 XSSF 从 excel 的特定单元格中读取数据,但不断收到错误 -

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 -

线程main"中的异常 java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions;在 org.apache.poi.POIXMLDocumentPart.(POIXMLDocumentPart.java:46)

这是我的一段代码:

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

我在构建路径中添加了以下 jar -

I have following jars added to build path -

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

我只能发现 setSaveAggressiveNamespaces 已经取代了 setSaveAggressiveNamespaces....

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

推荐答案

碰巧还有一个问题:xbean.jar 和 xmlbeans.jar 都有 XmlOptions,但只有 xmlbeans.jar 有你想要的方法.我首先更改了 xmlbeans.jar 的路径顺序并成功了.

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.

这篇关于无法在 Excel 2007 中使用 XSSF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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