无法打开使用Android应用程序Word文件 [英] unable to open a word file using android app

查看:146
本文介绍了无法打开使用Android应用程序Word文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已保存的.docx扩展名的文件在我的app.the文件保存在SD卡中。出现文件显示为SD卡我的Word文件,但我无法打开它(使用北极星或任何其他默认的软件)和消息不支持的文件。

I have saved a file with .docx extension in my app.the file is saved in the sdcard. The file appears as a word file in my sdcard but I am unable to open it (using polaris or any other default software) and message"unsupported file" appears.

当我保存文件,扩展名为.txt,我可以打开它。

When I save the file with .txt extension, I can open it.

    public void Savedoc(View v)
    {
        String filename = "file" + sn + ".docx";
         String filepath = "MyFileStorage";

         myExternalFile = new File(getExternalFilesDir(filepath), filename);


         try {
                FileOutputStream fos = new FileOutputStream(myExternalFile);
                fos.write(ly.getBytes());
                fos.close();
               } catch (IOException e) {
                e.printStackTrace();
               }


    }

感谢您的Alexandru ......但现在我得到上运行的应用程序,指出错误消息.PLS帮助这个元素的Javadoc既不能在附带的源,也没有附加的Javadoc中找到...

thank you alexandru ...but now i get an error message on running the app stating "The Javadoc for this element could neither be found in the attached source nor the attached Javadoc".pls help...

推荐答案

您需要使用的Apache POI 为了正确地创建一个 .DOCX 文件。

You'll need to use Apache POI in order to correctly create a .docx file.

我发现这个答案用code片断:

I've found this answer with a code snippet:

XWPFDocument document = new XWPFDocument();
XWPFParagraph tmpParagraph = document.createParagraph();
XWPFRun tmpRun = tmpParagraph.createRun();
tmpRun.setText("LALALALAALALAAAA");
tmpRun.setFontSize(18);
document.write(new FileOutputStream(new File("yourpathhere")));

您可以找到有关详细信息如何这里使用XWPF。

You may find more information about how to use XWPF here.

这篇关于无法打开使用Android应用程序Word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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