简体   繁体   中英

How to display DOCX document in Android

I am facing issue while parsing and displaying DOCX document in Android. I am new in this. I have tried parsing docx in java using Apache POI and it works fine. Its little heavy as it needs a lot of jars to execute the code. Below is the sample code in Java:

FileInputStream fis = new FileInputStream(docPath); 
XWPFDocument document = new XWPFDocument(OPCPackage.open(fis));
XWPFWordExtractor extractor = new XWPFWordExtractor(document);
System.out.println(extractor.getText());

It displays the input stream.

In case of Android I am facing isssue. It gives error like duplicate xmlbeans stuff in xmlBean jar. I read about it that Android is very strict about duplicate files and it produces issue while java not. On top, Apache POI is little bulky as well as it contanis lot of jars and takes alot of space. i am looking for a simple solution for this.

Please help me out.

Thanks in advance.

There is no direct way to show your docx file into WebView , instead you can use AndroidDocxToHtml library , here is the link below:-

https://github.com/plutext/AndroidDocxToHtml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM