验证和读取一个Word文件中的Andr​​oid文件、Word、oid、Andr

2023-09-12 07:37:05 作者:孤城少年~

我希望能够访问一个字文件在用户的手机的SD卡,该文件将被用户选择。我希望能够处理文件,即读其内容,并修改它,因为用户的意愿,并保存当用户点击保存。

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."

是否有可能在Android的?如何让程序知道该文件是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.

的code片这样的:

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.