Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open Excel, .doc files in Webview in Android?

Tags:

android

How can I open Excel and .doc file in Android webview. Can google doc support it?

like image 411
Ashwani Tyagi Avatar asked Oct 09 '12 10:10

Ashwani Tyagi


People also ask

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.

How do I open a PDF file from internal storage in WebView Android programmatically?

Opening a PDF file in Android using WebView All you need to do is just put WebView in your layout and load the desired URL by using the webView. loadUrl() function. Now, run the application on your mobile phone and the PDF will be displayed on the screen.


1 Answers

Yes Google doc support you to show doc or excel , pdf, txt or other formate.

WebView urlWebView = (WebView)findViewById(R.id.containWebView);
urlWebView.setWebViewClient(new AppWebViewClients());
urlWebView.getSettings().setJavaScriptEnabled(true);
urlWebView.getSettings().setUseWideViewPort(true);
urlWebView.loadUrl("http://docs.google.com/gview?embedded=true&url="
                + "YOUR_DOC_URL_HERE"); 

public class AppWebViewClients extends WebViewClient {



    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        // TODO Auto-generated method stub
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        // TODO Auto-generated method stub
        super.onPageFinished(view, url);

    }
}
like image 190
Md Abdul Gafur Avatar answered Oct 07 '22 22:10

Md Abdul Gafur