Sou*_*der 14 java eclipse excel android apache-poi
我有一个非常简单的问题:如何在Android上创建.docx和.xlsx文件.在有人将此标记为重复之前,请允许我告诉您,我已经尝试使用Apache POI创建它们,并且在这些问题中描述了我的尝试:
使用Apache POI创建.xlsx文件时的java.lang.NoClassDefFoundError
但是,如这些链接中所述,我收到java.lang.verify错误.这些是我最终导入到参考库中的jar文件:
dom4j的-1.6.1.jar
POI-3.10-FINAL-20140208.jar
POI-OOXML-3.10-FINAL-20140208.jar
STAX的API-1.0.1.jar
XMLBeans的-2.3.0.jar
POI-OOXML-模式-3.10-FINAL-20140208.jar
公地编解码器1.5.jar
共享记录-1.1.jar
基于JUnit 4.11.jar
log4j的-1.2.13.jar
但现在根本没有编译,并在控制台上说
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
[2014-02-19 16:59:24 - test] Dx 1 error; aborting
[2014-02-19 16:59:24 - test] Conversion to Dalvik format failed with error 1
Run Code Online (Sandbox Code Playgroud)
请告知我要做什么.
编辑:
我的最终目的是:我希望创建 .docx和.xlsx文件,并为它们添加一些内容.创建文件后,我应该能够在已连接手机的PC系统上成功查看它们.
编辑2:通过删除所有这些依赖项并使用 jspreadsheet-1.0 jar文件找到生成.xlsx文件的变通方法.但我仍然不知道该怎么做.docx文件.
更新的问题:
看来我的问题在于使用Android不支持的POI jar文件.有人可以请给我链接,我可以获得专门针对Android的 POI 吗?
或者,有人可以告诉我如何创建我可以添加内容的.docx文件,以便可以查看它们吗?
小智 1
通常你只需要这样做:
FileOutputStream archivoSalida;
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sht = wb.createSheet("Conciliacion");
...
...
archivoSalida = new FileOutputStream(fileDestination);
wb.write(archivoSalida);
archivoSalida.close();
Run Code Online (Sandbox Code Playgroud)
但看来你的问题不在代码中。是在库和编译中。我错了?