Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validating and reading a Word file in Android

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

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

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.

like image 390
Ashwin Avatar asked May 11 '12 09:05

Ashwin


People also ask

How do you validate a Word document?

Right-click the underlined word, and then choose the suggestion you want, or learn more about the error and how to correct it. Or, open the Editor pane to address issues by category. On the Review tab, select Check Document.

How can I open Word programmatically in Android?

Here is the complete way to open . doc file in Android 7.0 or less: Step-1: First of all, place your pdf file in assets folder like the following screenshot. Step-3: Now add a new java file which should extend from FileProvider Like in my case file name is LegacyCompatFileProvider and code inside of it.


1 Answers

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

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

Piece of code like:

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

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.

like image 87
Barmaley Avatar answered Oct 30 '22 22:10

Barmaley