Skip to content

android word文档预览 基于poi的word(.doc/.docx)转html 实现预览功能

Notifications You must be signed in to change notification settings

rny/android-word2html

 
 

Repository files navigation

android-word2html

Visit Count(from 2021/04/02)

Add Library

//build.gradle
allprojects {
    repositories {
        ...
	    maven { url 'https://jitpack.io' }
    }
}
//app/build.gradle
android{
    defaultConfig{
        ...
        multiDexEnabled true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.github.RDSunhy:android-word2html:1.2.0'
}


//If this fails
//You can Import Module (android_word2html)

Example

BasicSet basicSet = new BasicSet(
        MainActivity.this,
        sourceFilePath,//word file path
        htmlFilePath,//after conver html file storage path
        htmlFileName);//html fileName
//Some configuration can be added...
//The concrete in BasicSet.class
//basicSet.setHtmlBegin(htmlBegin);
String htmlSavePath = WordUtils.getInstance(basicSet).word2html();

...
//Render in a webview
webView.loadUrl("file://"+htmlSavePath);

Known Bug

  I can't set the image to fit the screen width
  I tried to style the label
  //String imgBegin = "<img src=\"%s\" width=\"100%\" height=\"auto\">";
  //basicSet.setImgBegin(imgBegin);
  But it failed...

About

android word文档预览 基于poi的word(.doc/.docx)转html 实现预览功能

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%