Open jacky-1 opened 3 years ago
Android does not provide the java.awt. packages and also actively refuses if you try to add such classes, this means any part of Apache POI which uses java.awt. stuff will currently fail this way.
I did some workaround with shading for java.awt.Color before, you can try to do the same for Dimension, see https://github.com/centic9/poi-on-android/blob/master/poishadow/build.gradle#L39 and https://github.com/centic9/poi-on-android/tree/master/poishadow/src/main/java/org/apache/poi/java/awt
I have now cherry-picked changes from https://github.com/LePat/poi-on-android/commit/d38372bd33860088c533f0838ee8830b3a945859 onto branch https://github.com/centic9/poi-on-android/commits/add_dummy_autosize to show how such missing classes from java.awt can be added.
But as the implementation just provides dummy implementations of the methods, I did not merge it into master. The resulting autosized column widths are far off and will not be useful unless a more sophisticated solution is implemented.
If you just want to get SXSSFWorkbook to work should be able to fetch these changes from there in your fork.
It can also serve as example of how to add a more useful implementation in the future.
The same issue is triggered by calling Sheet.autoSizeColumn(Int row)
, this also needs the FontRenderContext
.
Thanks for adding the example of how to add implementations for missing classes!
SXSSFWorkbook is the Streaming version of XSSFWorkbook, It allows to write very large files without running out of memory as only a configurable portion of the rows are kept in memory at any one time. This feature is quite relevant to Android where memory is not abundant. https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/streaming/SXSSFWorkbook.html stack trace:
the issue can be easily replicated by modifying the method writeWorkbook() in DocumentListActivity.java of the piotest module. to the following: