一、POI方式
1.先看word效果图
2.再看下在android上使用WebView显示的效果
3. 生成的html的代码,如下:
1 2 3 4 22广东省药品生产企业现场检查表 23 24 25 2627 企业产品信息表 28
29 30
34 35 企业名称 36 37 | 38 39 $QYMC$ 40 41 | 42 ||
45 46 企业地址 47 48 | 49 50 $QYDZ 51 52 | 53 ||
56 57 企业负责人 58 59 | 60 61 $QYFZR 62 63 | 64 ||
67 68 法人代表 69 70 | 71 72 $FRDB 73 74 | 75 76 创建时间 77 78 | 79 80 $CJSJ 81 82 | 83
86 87 企业 88 89 9091 生产 92 93 9495 品种 96 97 9899 描述100 101 102103 以及104 105 106107 存在108 109 110111 问题112 113 | 114 115 $SCPZMSJWT116 117 | 118 ||
121 122 结论123 124125 以及126 127128 解决129 130131 方法132 133 | 134 135 $JLJJJFF136 137 | 138 ||
141 142 企业负责人签名:$QYFZRQM$143 144 | 145 |||
148 149 产品人员签名:$CPRWQM$150 151 | 152 |||
155 156 执法证号: $ZFZH$157 158 | 159 |||
162 163 备注:$BZ$164 165 | 166
172
173 1744.在浏览器上显示也是不居中,如图:
5.根据上面的情况,方案1
因为在手机上的table内容不能够居中。所以在table标签上增加一个属性 align="center"
然后,在浏览器上就可以居中显示了。如果这种方法可以实现,就是读脚本,然后找到<table class="t1">标签换成上面的代码即可。不过普适性就大大降低了。但是这种方法生成的html在Webview上显示依然是不居中。所以该方案被抛弃了。
二、jacob方式
以前做J2EE的时候,用POI比较多,对这个不是太了解。网上直接度jacod,但是很难找到官方网站。 这个才是它的官网。另附一个下载地址:
用as搭了环境,也写了点代码,但是问题出来了。最后发现,这样不行,似乎只能在Java环境中使用。
1 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: FATAL EXCEPTION: main 2 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: java.lang.ExceptionInInitializerError 3 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.tongyan.demo.MainActivity.word2Html(MainActivity.java:39) 4 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.tongyan.demo.MainActivity.access$000(MainActivity.java:13) 5 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.tongyan.demo.MainActivity$1.onClick(MainActivity.java:31) 6 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.view.View.performClick(View.java:4095) 7 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:16977) 8 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:615) 9 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:92)10 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)11 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4745)12 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)13 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)14 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)15 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)16 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)17 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jacob: findLibrary returned null18 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at java.lang.Runtime.loadLibrary(Runtime.java:365)19 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at java.lang.System.loadLibrary(System.java:535)20 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.jacob.com.Dispatch.(Dispatch.java)21 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.tongyan.demo.MainActivity.word2Html(MainActivity.java:39) 22 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.tongyan.demo.MainActivity.access$000(MainActivity.java:13) 23 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.tongyan.demo.MainActivity$1.onClick(MainActivity.java:31) 24 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.view.View.performClick(View.java:4095) 25 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:16977) 26 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:615) 27 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:92) 28 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137) 29 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4745) 30 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 31 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511) 32 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 33 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 34 02-22 13:28:48.168 5793-5793/com.tongyan.demo E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
参考资料:
三、openoffice方式