Issue
I tried to use XSSF (.xlsx) in android
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLStreamReader;
at org.apache.xmlbeans.XmlBeans.buildStreamToNodeMethod(XmlBeans.java:251)
...
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLStreamReader" on path: DexPathList[[zip file "/data/app/com.sariazhariyah.eassessmentinteraktif-4sjKuPiaYY6uCxQV1fSGmg==/base.apk"],nativeLibraryDirectories=[/data/app/com.sariazhariyah.eassessmentinteraktif-4sjKuPiaYY6uCxQV1fSGmg==/lib/arm, /data/app/com.sariazhariyah.eassessmentinteraktif-4sjKuPiaYY6uCxQV1fSGmg==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
it does not show an error when I use HSSF, but HSSF border has been deprecated, I need to use the border in my excel file
this example code I used
Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue(1);
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(
createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
try (OutputStream fileOut = new FileOutputStream("workbook.xlsx")) {
wb.write(fileOut);
}catch (IOException e){
Log.d("SaveData Exception","Error"+e);
}
Solution
Just change
XSSFWorkbook();
to
HSSFWorkbook();
This help for me. Don't foget
implementation 'org.apache.poi:poi:4.1.2'
implementation 'org.apache.poi:poi-ooxml:4.1.2'
Answered By - Marriage
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.