3

I want to view excel files in my own Android App.

Currently, using my App I can see all google docs. But after clicking on any one doc (for e.g Excel file 'myDemo.xls') , I want to open it in my own app (For Viewing purpose).

I have read about jxl but the problem with this is that it parses the xls file & the file should be stored in the SD Card.

In my case it is stored in the google drive. (not on SD card)

Here is similar question.

Is there any other way to view xls file through any other API.

Any help will be appreciated.

Thanks

I have used the WebView to achieve this.

But the problem is , by using webview I am not able to update the google docs.

I want user to update the google docs using my App through webview.

Below is my code that i've tried up till now,

MainActivity.java

public class MainActivity extends ActionBarActivity {

WebView wbView1;

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    wbView1=(WebView)findViewById(R.id.webView1);
    wbView1.getSettings().setLoadsImagesAutomatically(true);
    wbView1.getSettings().setJavaScriptEnabled(true);
    wbView1.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    wbView1.getSettings().setBuiltInZoomControls(true);
    wbView1.getSettings().setSupportZoom(true);
    wbView1.getSettings().setAllowContentAccess(true);
    wbView1.setWebViewClient(new MyBrowser());

    }

// Button on clicking on which I am loading google docs url in WebView.
public void onButtonClick(View v) {
    wbView1.loadUrl("https://docs.google.com/spreadsheets/d/15L4VenowOI0WPO52ASSjRgf90LcNxuJg8VF87_DtTp8/edit#gid=1311977634");

    return;
}


public class MyBrowser extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
       view.loadUrl(url);
       return true;
    }
    @Override
    public void onPageFinished(WebView view, String url) 
    {       
        view.loadUrl("javascript:document.forms[0].q.value='[android]'"); 
    }

 }

}

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.webviewdemo.MainActivity"
tools:ignore="MergeRootFrame" >

<WebView
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight=".4" 
    android:clickable="true"/>

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:onClick="onButtonClick"
    android:text="Button" />

</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.webviewdemo"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.webviewdemo.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

Can the google docs be edited inside WebView or Google Drive API is required for editing the docs?

I am really confused . Pls help.

Community
  • 1
  • 1
krohit
  • 792
  • 1
  • 7
  • 26
  • https://github.com/dennis-sheil/android-spreadsheet – Dhaval Aug 27 '14 at 11:49
  • @ Dhaval: Thanks for your quick reply :) But this not the solution I am looking for. I only want to open the xls file not parse it. I think [WebView](http://developer.android.com/reference/android/webkit/WebView.html) can be the solution. But it opens browser viz. an external application.Hence, My new question is that Can WebView be used to open browser within my Application? – krohit Aug 27 '14 at 12:18
  • any solution for this matter ? – user987760 Jun 10 '19 at 15:49
  • @user987760 Nope – krohit Jun 12 '19 at 10:29

0 Answers0