Android + Proguard + Apache POI

前端 未结 2 650
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 19:38

Someone was able to get the Apache POI library to work after obfuscation. I read a lot of information, tried different methods, but still get the error:

a.a.         


        
相关标签:
2条回答
  • 2021-01-18 20:06

    EDITED

    From https://github.com/centic9/poi-on-android

    Necessary System-Properties

    In order to work around problems with finding a suitable XML Parser, currently the following system properties need to be set manually during startup of your application (let me know if you know of a better way to do this, see issue #10)

    From me : Just put those lines in your code before using the library

    System.setProperty("org.apache.poi.javax.xml.stream.XMLInputFactory", "com.fasterxml.aalto.stax.InputFactoryImpl");
    System.setProperty("org.apache.poi.javax.xml.stream.XMLOutputFactory", "com.fasterxml.aalto.stax.OutputFactoryImpl");
    System.setProperty("org.apache.poi.javax.xml.stream.XMLEventFactory", "com.fasterxml.aalto.stax.EventFactoryImpl");
    

    Download the library

    If you want to get started quickly, there is a ready-made jar-file available here https://github.com/centic9/poi-on-android/releases

    You should be able to simply add this to your Android project and use the Apache POI classes from it.

    For ProGuard

    -dontwarn org.apache.**
    -dontwarn org.openxmlformats.schemas.**
    -dontwarn org.etsi.**
    -dontwarn org.w3.**
    -dontwarn com.microsoft.schemas.**
    -dontwarn com.graphbuilder.**
    -dontnote org.apache.**
    -dontnote org.openxmlformats.schemas.**
    -dontnote org.etsi.**
    -dontnote org.w3.**
    -dontnote com.microsoft.schemas.**
    -dontnote com.graphbuilder.**
    
    -keeppackagenames org.apache.poi.ss.formula.function
    
    -keep class com.fasterxml.aalto.stax.InputFactoryImpl
    -keep class com.fasterxml.aalto.stax.OutputFactoryImpl
    -keep class com.fasterxml.aalto.stax.EventFactoryImpl
    
    -keep class schemaorg_apache_xmlbeans.system.sF1327CCA741569E70F9CA8C9AF9B44B2.TypeSystemHolder { public final static *** typeSystem; }
    
    -keep class org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem { public static *** get(...); public static *** getNoType(...); }
    -keep class org.apache.xmlbeans.impl.schema.PathResourceLoader { public <init>(...); }
    -keep class org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler { public static *** compile(...); }
    -keep class org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl { public <init>(...); public static *** get(...); public static *** getNoType(...); }
    -keep class org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl { public static *** getContextTypeLoader(...); public static *** build(...); }
    -keep class org.apache.xmlbeans.impl.store.Locale { public static *** streamToNode(...); public static *** nodeTo*(...); }
    -keep class org.apache.xmlbeans.impl.store.Path { public static *** compilePath(...); }
    -keep class org.apache.xmlbeans.impl.store.Query { public static *** compileQuery(...); }
    
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CommentsDocument { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAuthors { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorders { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStyleXfs { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentList { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDrawing { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFills { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFonts { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontName { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontScheme { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontSize { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIntProperty { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTLegacyDrawing { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmts { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPane { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSelection { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetData { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetDimension { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetFormatPr { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetView { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetViews { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheets { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType$Enum { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType$Enum { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.STXstring { *; }
    
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CommentsDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTAuthorsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBooleanPropertyImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBookViewImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBookViewsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBorderImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBordersImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBorderPrImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellAlignmentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellFormulaImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellStyleXfsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellXfsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTColorImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTColImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTColsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCommentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCommentsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCommentListImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTDrawingImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFillImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFillsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontNameImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontSchemeImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontSizeImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTIntPropertyImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTLegacyDrawingImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTNumFmtsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTPatternFillImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTPageMarginsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTPaneImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTRowImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSelectionImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetDataImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetDimensionImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetFormatPrImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetViewImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetViewsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSstImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTStylesheetImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTRstImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorkbookImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorkbookPrImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTXfImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.SstDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.StyleSheetDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.STXstringImpl { *; }
    
    -keep class org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl.CTPropertiesImpl { *; }
    -keep class org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl.PropertiesDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl.CTPropertiesImpl { *; }
    -keep class org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl.PropertiesDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl.CTDrawingImpl { *; }
    -keep class org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl.CTMarkerImpl { *; }
    -keep class com.microsoft.schemas.office.office.impl.CTIdMapImpl { *; }
    -keep class com.microsoft.schemas.office.office.impl.CTShapeLayoutImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTShadowImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTFillImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTPathImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTShapeImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTShapetypeImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTStrokeImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTTextboxImpl { *; }
    -keep class com.microsoft.schemas.office.excel.impl.CTClientDataImpl { *; }
    -keep class com.microsoft.schemas.office.excel.impl.STTrueFalseBlankImpl { *; }
    

    Old answer (does not work on Android if ProGuard is enabled)

    If you use HSSF

    ( .xls => Excel '97(-2007) file format) It was not easy but I succeeded. Simply set this dependency to Apache POI (ONLY, remove the libraries add previously ex : poi-ooxml-schemas-3.12-20150511-a.jar and poi-3.12-android-a.jar) :

    compile group: 'org.apache.poi', name: 'poi', version: '3.16'
    

    For the latest version see here : https://mvnrepository.com/artifact/org.apache.poi/poi

    If you use SXSSF

    (.xlsx => Excel 2007 OOXML file format) Add this dependency to your build.gradle

    compile files('libs/poi-3.12-android-a.jar')
    compile files('libs/poi-ooxml-schemas-3.12-20150511-a.jar')
    

    The ProGuard Rules for both

    And for ProGuard just add the rules quote by @PN10 above: https://github.com/centic9/poi-on-android/issues/5#issuecomment-283581644

    # Optimize
    -optimizations !field/*,!class/merging/*,*
    -mergeinterfacesaggressively
    
    # will keep line numbers and file name obfuscation
    -renamesourcefileattribute SourceFile
    -keepattributes SourceFile,LineNumberTable
    
    # Apache POI
    -dontwarn org.apache.**
    -dontwarn org.openxmlformats.schemas.**
    -dontwarn org.etsi.**
    -dontwarn org.w3.**
    -dontwarn com.microsoft.schemas.**
    -dontwarn com.graphbuilder.**
    -dontnote org.apache.**
    -dontnote org.openxmlformats.schemas.**
    -dontnote org.etsi.**
    -dontnote org.w3.**
    -dontnote com.microsoft.schemas.**
    -dontnote com.graphbuilder.**
    
    -keeppackagenames org.apache.poi.ss.formula.function
    
    -keep class com.fasterxml.aalto.stax.InputFactoryImpl
    -keep class com.fasterxml.aalto.stax.OutputFactoryImpl
    -keep class com.fasterxml.aalto.stax.EventFactoryImpl
    
    -keep class schemaorg_apache_xmlbeans.system.sF1327CCA741569E70F9CA8C9AF9B44B2.TypeSystemHolder { public final static *** typeSystem; }
    
    -keep class org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem { public static *** get(...); public static *** getNoType(...); }
    -keep class org.apache.xmlbeans.impl.schema.PathResourceLoader { public <init>(...); }
    -keep class org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler { public static *** compile(...); }
    -keep class org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl { public <init>(...); public static *** get(...); public static *** getNoType(...); }
    -keep class org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl { public static *** getContextTypeLoader(...); public static *** build(...); }
    -keep class org.apache.xmlbeans.impl.store.Locale { public static *** streamToNode(...); public static *** nodeTo*(...); }
    -keep class org.apache.xmlbeans.impl.store.Path { public static *** compilePath(...); }
    -keep class org.apache.xmlbeans.impl.store.Query { public static *** compileQuery(...); }
    
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CommentsDocument { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAuthors { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorders { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStyleXfs { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentList { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDrawing { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFills { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFonts { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontName { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontScheme { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontSize { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIntProperty { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTLegacyDrawing { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmts { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPane { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSelection { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetData { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetDimension { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetFormatPr { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetView { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetViews { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheets { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType$Enum { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType$Enum { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.STXstring { *; }
    
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CommentsDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTAuthorsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBooleanPropertyImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBookViewImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBookViewsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBorderImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBordersImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTBorderPrImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellAlignmentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellFormulaImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellStyleXfsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCellXfsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTColorImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTColImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTColsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCommentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCommentsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTCommentListImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTDrawingImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFillImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFillsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontNameImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontSchemeImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontSizeImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTIntPropertyImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTLegacyDrawingImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTNumFmtsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTPatternFillImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTPageMarginsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTPaneImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTRowImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSelectionImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetDataImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetDimensionImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetFormatPrImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetViewImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetViewsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSheetsImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTSstImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTStylesheetImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTRstImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorkbookImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorkbookPrImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTWorksheetImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTXfImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.SstDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.StyleSheetDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.STXstringImpl { *; }
    
    -keep class org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl.CTPropertiesImpl { *; }
    -keep class org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl.PropertiesDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl.CTPropertiesImpl { *; }
    -keep class org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl.PropertiesDocumentImpl { *; }
    -keep class org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl.CTDrawingImpl { *; }
    -keep class org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl.CTMarkerImpl { *; }
    -keep class com.microsoft.schemas.office.office.impl.CTIdMapImpl { *; }
    -keep class com.microsoft.schemas.office.office.impl.CTShapeLayoutImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTShadowImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTFillImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTPathImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTShapeImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTShapetypeImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTStrokeImpl { *; }
    -keep class com.microsoft.schemas.vml.impl.CTTextboxImpl { *; }
    -keep class com.microsoft.schemas.office.excel.impl.CTClientDataImpl { *; }
    -keep class com.microsoft.schemas.office.excel.impl.STTrueFalseBlankImpl { *; }
    
    0 讨论(0)
  • 2021-01-18 20:32

    you can use the latest poi 3.17 without any significant modification to the original library for excel xlsx format and run this successfully on android provided you have eliminate all those duplicate classes bundle in the xmlbeans-2.6.0.jar and not forgetting these two required stax and stax-api jar library too . If you do run proguard , please be extra careful not to obfuscate relevant important classes such as com.bea.xml.** and the rest in the xmlbeans and some schema required by poi. ProGuard Rules Example as shown below. If the Api is less than 20 or below and in certain phone models , the full drawing and spreadsheet package in the ooxml-schemas-1.3.jar is somehow required to avoid class not found error.

    jar link

    -keep class org.** { *; }
    -keep class com.bea.xml.stream.**{*;}
    -keep class org.apache.xmlbeans.** { *; }
    -keep class com.microsoft.** { *; }
    -keep class org.openxmlformats.**{*;}``
    -keep class com.apache.poi.** { *; }
    -keep class schemaorg_apache_xmlbeans.** {*;}
    

    link to post

    0 讨论(0)
提交回复
热议问题