一、POI方式
1.先看word效果图
2.再看下在android上使用WebView显示的效果
3. 生成的html的代码,如下:
1 <html> 2 <head> 3 <META http-equiv="Content-Type" content="text/html; charset=utf-8"> 4 <style type="text/css">.b1{white-space-collapsing:preserve;} 5 .b2{margin: 1.2590277in 1.0in 0.41944444in 1.1027777in;} 6 .s1{font-weight:bold;} 7 .p1{text-align:center;hyphenate:auto;font-family:Times New Roman;font-size:22pt;} 8 .p2{text-align:center;hyphenate:auto;font-family:Times New Roman;font-size:12pt;} 9 .p3{text-align:justify;hyphenate:auto;font-family:Times New Roman;font-size:10pt;} 10 .p4{text-align:center;hyphenate:auto;font-family:Times New Roman;font-size:10pt;} 11 .td1{width:0.75625in;padding-start:0.0in;padding-end:0.0in;border-bottom:thin solid black;border-left:thin solid black;border-right:thin solid black;border-top:thin solid black;} 12 .td2{width:5.4625in;padding-start:0.0in;padding-end:0.0in;border-bottom:thin solid black;border-left:thin solid black;border-right:thin solid black;border-top:thin solid black;} 13 .td3{width:3.4208333in;padding-start:0.0in;padding-end:0.0in;border-bottom:thin solid black;border-left:thin solid black;border-right:thin solid black;border-top:thin solid black;} 14 .td4{width:0.875in;padding-start:0.0in;padding-end:0.0in;border-bottom:thin solid black;border-left:thin solid black;border-right:thin solid black;border-top:thin solid black;} 15 .td5{width:1.1666666in;padding-start:0.0in;padding-end:0.0in;border-bottom:thin solid black;border-left:thin solid black;border-right:thin solid black;border-top:thin solid black;} 16 .td6{width:6.21875in;padding-start:0.0in;padding-end:0.0in;border-bottom:thin solid black;border-left:thin solid black;border-right:thin solid black;border-top:thin solid black;} 17 .r1{keep-together:always;} 18 .r2{height:0.3236111in;keep-together:always;} 19 .r3{height:0.32430556in;keep-together:always;} 20 .t1{table-layout:fixed;border-collapse:collapse;border-spacing:0;} 21 </style> 22 <title>广东省药品生产企业现场检查表</title> 23 <meta name="author" content="张芳向 Netboy"> 24 </head> 25 <body class="b1 b2"> 26 <p class="p1"> 27 <span class="s1">企业产品信息表</span> 28 </p> 29 <p class="p2"></p> 30 <table class="t1"> 31 <tbody> 32 <tr class="r1"> 33 <td class="td1"> 34 <p class="p3"> 35 <span>企业名称</span> 36 </p> 37 </td><td colspan="3" class="td2"> 38 <p class="p3"> 39 <span>$QYMC$</span> 40 </p> 41 </td> 42 </tr> 43 <tr class="r1"> 44 <td class="td1"> 45 <p class="p3"> 46 <span>企业地址</span> 47 </p> 48 </td><td colspan="3" class="td2"> 49 <p class="p3"> 50 <span>$QYDZ</span> 51 </p> 52 </td> 53 </tr> 54 <tr class="r1"> 55 <td class="td1"> 56 <p class="p3"> 57 <span>企业负责人</span> 58 </p> 59 </td><td colspan="3" class="td2"> 60 <p class="p3"> 61 <span>$QYFZR</span> 62 </p> 63 </td> 64 </tr> 65 <tr class="r1"> 66 <td class="td1"> 67 <p class="p3"> 68 <span>法人代表</span> 69 </p> 70 </td><td class="td3"> 71 <p class="p3"> 72 <span>$FRDB</span> 73 </p> 74 </td><td class="td4"> 75 <p class="p3"> 76 <span>创建时间</span> 77 </p> 78 </td><td class="td5"> 79 <p class="p3"> 80 <span>$CJSJ</span> 81 </p> 82 </td> 83 </tr> 84 <tr class="r1"> 85 <td class="td1"> 86 <p class="p4"> 87 <span>企业</span> 88 </p> 89 <p class="p4"></p> 90 <p class="p4"> 91 <span>生产</span> 92 </p> 93 <p class="p4"></p> 94 <p class="p4"> 95 <span>品种</span> 96 </p> 97 <p class="p4"></p> 98 <p class="p4"> 99 <span>描述</span> 100 </p> 101 <p class="p4"></p> 102 <p class="p4"> 103 <span>以及</span> 104 </p> 105 <p class="p4"></p> 106 <p class="p4"> 107 <span>存在</span> 108 </p> 109 <p class="p4"></p> 110 <p class="p4"> 111 <span>问题</span> 112 </p> 113 </td><td colspan="3" class="td2"> 114 <p class="p3"> 115 <span>$SCPZMSJWT</span> 116 </p> 117 </td> 118 </tr> 119 <tr class="r1"> 120 <td class="td1"> 121 <p class="p3"> 122 <span> 结论</span> 123 </p> 124 <p class="p4"> 125 <span>以及</span> 126 </p> 127 <p class="p4"> 128 <span>解决</span> 129 </p> 130 <p class="p4"> 131 <span>方法</span> 132 </p> 133 </td><td colspan="3" class="td2"> 134 <p class="p3"> 135 <span>$JLJJJFF</span> 136 </p> 137 </td> 138 </tr> 139 <tr class="r2"> 140 <td colspan="4" class="td6"> 141 <p class="p3"> 142 <span>企业负责人签名:$QYFZRQM$</span> 143 </p> 144 </td> 145 </tr> 146 <tr class="r2"> 147 <td colspan="4" class="td6"> 148 <p class="p3"> 149 <span>产品人员签名:$CPRWQM$</span> 150 </p> 151 </td> 152 </tr> 153 <tr class="r2"> 154 <td colspan="4" class="td6"> 155 <p class="p3"> 156 <span>执法证号: $ZFZH$</span> 157 </p> 158 </td> 159 </tr> 160 <tr class="r3"> 161 <td colspan="4" class="td6"> 162 <p class="p3"> 163 <span>备注:$BZ$</span> 164 </p> 165 </td> 166 </tr> 167 </tbody> 168 </table> 169 <p class="p3"></p> 170 <p class="p3"></p> 171 <p class="p3"> 172 <img src="test/0.jpg" style="width:6.1604166in;height:3.85in;vertical-align:text-bottom;"></p> 173 </body> 174 </html>
4.在浏览器上显示也是不居中,如图:
5.根据上面的情况,方案1
因为在手机上的table内容不能够居中。所以在table标签上增加一个属性 align="center"
<table align="center" class="t1">
然后,在浏览器上就可以居中显示了。如果这种方法可以实现,就是读脚本,然后找到<table class="t1">标签换成上面的代码即可。不过普适性就大大降低了。但是这种方法生成的html在Webview上显示依然是不居中。所以该方案被抛弃了。
二、jacob方式
以前做J2EE的时候,用POI比较多,对这个不是太了解。网上直接度jacod,但是很难找到官方网站。http://danadler.com/jacob/ 这个才是它的官网。另附一个下载地址:https://sourceforge.net/projects/jacob-project/
三、openoffice方式
时间: 2024-12-15 07:10:16