如何解决java.lang.VerifyError:org / apache / poi / xssf / usermodel / XSSFWorkbook? [英] How to resolve the java.lang.VerifyError: org/apache/poi/xssf/usermodel/XSSFWorkbook?
问题描述
我正在尝试从资产文件夹中读取xlsx文件。我收到以下异常,
05-16 10:12:05.613:E / AndroidRuntime(2915):致命例外:main
05-16 10:12:05.613:E / AndroidRuntime(2915):java.lang.VerifyError:org / apache / poi / xssf / usermodel / XSSFWorkbook
在这个例外之前,我收到了一些警告,也就是,
-
找不到方法
org.openxmlformats.schemas.spreadsheetml.x2006.main.WorkbookDocument $ Factory.parse,
从方法
引用org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead
-
VFY:无法解决异常类3612
(Lorg / apache / xmlbeans / XmlException;)
我已经在我的应用程序中添加了poi 3.12库,图片截图如下,
我已经在Order和Export中检查了poi-3.12和poi-ooxml-3.12 jar文件,如下所示,截图如下,
我使用下面的代码,
InputStream is = context.getAssets()。open(sample.xlsx));
XSSFWorkbook工作簿=新的XSSFWorkbook(是);
XSSFSheet sheet = workbook.getSheetAt(0);
单元格= sheet.getRow(0).getCell(0);
String value = cell.getStringCellValue()+;
我想读写.XLSX和.XLS文件。如何解决这个问题?
感谢提前。
冷杉你应该连接到你的项目这些罐子。
然后使用此代码阅读
public static void readXLSXFile()throws IOException
{
InputStream ExcelFileToRead = new FileInputStream(C:/Test.xlsx);
XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
XSSFWorkbook test = new XSSFWorkbook();
XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow行;
XSSFCell单元格
迭代器行= sheet.rowIterator();
while(rows.hasNext())
{
row =(XSSFRow)rows.next();
迭代器单元格= row.cellIterator();
while(cells.hasNext())
{
cell =(XSSFCell)cells.next();
if(cell.getCellType()== XSSFCell.CELL_TYPE_STRING)
{
System.out.print(cell.getStringCellValue()+);
}
else if(cell.getCellType()== XSSFCell.CELL_TYPE_NUMERIC)
{
System.out.print(cell.getNumericCellValue()+);
}
else
{
// U Can Handel布尔值,公式,错误
}
}
System.out.println() ;
}
}
I'm trying to read the xlsx file from asset folder. I received below exception,
05-16 10:12:05.613: E/AndroidRuntime(2915): FATAL EXCEPTION: main 05-16 10:12:05.613: E/AndroidRuntime(2915): java.lang.VerifyError: org/apache/poi/xssf/usermodel/XSSFWorkbook
before this exception, I received some warnings also like,
Could not find method org.openxmlformats.schemas.spreadsheetml.x2006.main.WorkbookDocument$Factory.parse, referenced from method org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead
VFY: unable to resolve exception class 3612 (Lorg/apache/xmlbeans/XmlException;)
I have added poi 3.12 library on my application, libraries screenshot as below,
And I have checked poi-3.12 and poi-ooxml-3.12 jar files in Order and Export, screenshot as below,
I used below code,
InputStream is = context.getAssets().open("sample.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(is);
XSSFSheet sheet = workbook.getSheetAt(0);
Cell cell = sheet.getRow(0).getCell(0);
String value = cell.getStringCellValue() + "";
I want to read and write the .XLSX and .XLS files. How to resolve this issue?
Thanks in Advance.
Firs you should connect to your project these jars.
Then use this code for reading
public static void readXLSXFile() throws IOException
{
InputStream ExcelFileToRead = new FileInputStream("C:/Test.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
XSSFWorkbook test = new XSSFWorkbook();
XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow row;
XSSFCell cell;
Iterator rows = sheet.rowIterator();
while (rows.hasNext())
{
row=(XSSFRow) rows.next();
Iterator cells = row.cellIterator();
while (cells.hasNext())
{
cell=(XSSFCell) cells.next();
if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING)
{
System.out.print(cell.getStringCellValue()+" ");
}
else if(cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC)
{
System.out.print(cell.getNumericCellValue()+" ");
}
else
{
//U Can Handel Boolean, Formula, Errors
}
}
System.out.println();
}
}
这篇关于如何解决java.lang.VerifyError:org / apache / poi / xssf / usermodel / XSSFWorkbook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!