如何在Android上创建.docx文件和.xlsx文件 [英] How to create .docx files and .xlsx files on Android

查看:436
本文介绍了如何在Android上创建.docx文件和.xlsx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的问题:如何在Android上创建 .docx .xlsx 文件。在有人将此标记为重复之前,请告诉我,我已经广泛尝试使用Apache POI创建它们,我的尝试在这些问题中描述:



java.lang.NoClassDefFoundError / a>



使用poi-ooxml jar文件创建一个.docx文件



然而,正如这些链接所描述的那样,我得到了 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-schemas-3.10-FINAL-20140208.jar


  • commons-codec-1.5.jar


  • commons-logging-1.1.jar


  • junit-4.11.jar


  • log4j-1.2.13.jar




但现在它根本没有编译,并在控制台上说这个。

 不建议或错误地使用核心类(java。*或javax。*)
时不构建核心库。

这通常是由于在使用IDE(如
Eclipse)时在应用程序的项目中无意中包含一个核心库文件
。如果你确定你不是故意定义一个
的核心类,那么这是最有可能的解释是什么是


但是,您可能实际上正在尝试在一个核心
命名空间中定义一个类,其中您可能已经使用了这个类,例如来自非Android虚拟机的
机械工程。这个大多数
肯定不行。至少,它会损害您的应用程序与未来版本的平台的
兼容性。
这也常常是有争议的合法性。

如果您真的打算构建一个核心库,这只是
适合作为创建一个完整虚拟机
分发的一部分,而不是编译应用程序使用
--core-library选项来禁止此错误消息。

如果您继续使用--core-library,但实际上是
构建一个应用程序,则应该预先警告您的应用程序
仍然无法构建或运行, 在某一点。请为
准备为愤怒的客户找到,例如,一旦他们升级运行
系统,您的
应用程序将停止运行。你将会怪这个问题。

如果您合法使用一些恰好在
核心包中的代码,那么最简单的安全替代方案是
重新打包该代码。也就是说,将有问题的类移动到
你自己的包命名空间。这意味着它们永远不会与
与核心系统类冲突。 JarJar是一个工具,可以帮助你在这个努力
。如果你发现你不能这样做,那么
这表明你所在的路径最终会导致
的痛苦,痛苦,悲伤和悲哀。

[2014-02-19 16:59:24 - test] Dx 1错误;中止
[2014-02-19 16:59:24 - 测试]转换为Dalvik格式失败,出现错误1

请告知我要做什么。



编辑:



我的最终目的是:我希望创建 .docx和.xlsx文件,并向其添加一些内容。创建文件后,我可以在已连接手机的 PC系统上成功查看



编辑2:通过删除所有这些依赖项并使用 jspreadsheet-1.0找到解决方案来生成 .xlsx 文件 jar文件。但是我仍然不知道该如何处理 .docx 文件。



更新问题



看来我的问题在于使用Android不支持的POI jar文件。有人可以为我提供链接,我可以在 Android 中获得POI 具体的链接?或者,有人可以告诉我如何创建可以添加内容的 .docx 文件,以便可以查看?

解决方案

使用 Apache POI图书馆只是因为它是最好的。



Google还在其快速办公室 Android应用程序。



* x文件,如docx和xlsx,它可能对Dalvik允许的功能有一些限制。


I have a very simple question: How to create .docx and .xlsx files on Android. Before someone marks this as duplicate, let me tell you that I have extensively tried creating them using Apache POI and my attempts are described in these questions:

java.lang.NoClassDefFoundError while creating a .xlsx file using Apache POI

Creating a .docx file using poi-ooxml jar file

However, as described in those links, I am getting the java.lang.verify error. These are the jar files I have finally imported into my reference libraries:

  • 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-schemas-3.10-FINAL-20140208.jar

  • commons-codec-1.5.jar

  • commons-logging-1.1.jar

  • junit-4.11.jar

  • log4j-1.2.13.jar

but now it doesn't compile at all, and says this on the console

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

Please advise as to what I am to do.

EDIT:

My end purpose is: I wish to create .docx and .xlsx files and add some content to them. Once the files are created, I should be able to successfully view them on the PC system which I have connected the phone to.

EDIT 2: Found a workaround to generate .xlsx files by removing all these dependencies and using jspreadsheet-1.0 jar file. But I still don't know what to do for .docx files.

UPDATED QUESTION:

It seems my problem lies with using the POI jar files which is not supported by Android. Can someone please supply me the link where I can get POI specifically for Android?

Or, can someone please tell me how to create .docx files to which I can add content, and such that they can be viewed?

解决方案

Use Apache POI library only because It is the best out there.

Google also uses it in its Quick Office Application for Android.

For the .***x files like docx and xlsx, It might have some limits on the allowed functions in Dalvik.

这篇关于如何在Android上创建.docx文件和.xlsx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆