在 Android 中验证和读取 Word 文件 [英] Validating and reading a Word file in Android

查看:24
本文介绍了在 Android 中验证和读取 Word 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够访问用户手机sdcard中的word文件,该文件将由用户选择.我希望能够处理该文件,即读取其内容并根据用户的意愿进行修改,并在用户单击保存"时进行保存.

I want to be able to access a word file in the sdcard of the user's phone, and the file will be chosen by the user. I want to be able to process the file, i.e. read its contents and modify it as the user wishes, and save it when the user clicks "save."

在安卓中可以吗?如何让程序知道该文件是 Word 文件?

Is it possible in Android? How can I make the program understand that the file is a Word file?

请注意,我不想查看 Word 文件.用户将选择 Word 文件,我的应用应该能够对其进行一些更改并保存.

Note that I don't want to view the Word file. The user will select the Word file and my app should be able to make some changes to it and save it.

推荐答案

恕我直言,最简单的方法是移植 Apache POI 库到Android.这是可能的,并且有证明

Simplest way IMHO is to port Apache POI library to Android. It's possible and there proof of that

移植 POI,您可以将 Word 编辑功能嵌入到您的应用程序中.

Porting POI you can embed Word editing feature into your application.

代码如下:

Intent intent = new Intent(Intent.ACTION_EDIT); 
Uri uri = Uri.parse("file:///"+file.getAbsolutePath()); 
intent.setDataAndType(uri, "plain/text"); 
startActivity(intent);

仅表示 Word 文件将由其他应用程序编辑 - 而不是您的应用程序.据我了解,这不完全是您想要的.

Simply means that Word file will be edited by some other application - not yours. As far as I understand it's not exactly what you want.

这篇关于在 Android 中验证和读取 Word 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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