2017-01-26 81 views
0

我們使用Oracle BI Publisher創建可以寫入文件(pdf,excel,html ...)的數據。如何在打開HTML內容時格式化Excel單元格'文本'

我檢查了創建的數據,它是一個html頁面(包含格式和業務數據,由oracle bi發佈者使用XSL-FO創建)。我們使用java將數據寫入xls文件(不使用POI)。當數據包含'= cmd |'/ C calc'!A0'時,這個值在excel單元格中(常規單元格類型)會嘗試調用'cmd'來打開windows計算器(我們不希望發生這種情況) )。如果excel單元格格式爲「文本」,則值將會正常。

那麼我怎樣才能把這樣的html數據寫入excel中,所有的excel單元格格式都是'text'呢?或者任何其他方式來避免'= cmd |'/ C calc'!A0'問題在excel中?

<html> 
 
<!-- Generated by Oracle BI Publisher 11.1.1.6.0 --> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
 
<title></title> 
 
<style type="text/css" id="internalStyle"> 
 
.c0 {height: 26.25pt;} 
 
.c1 {word-wrap:break-word;width:14.999%;background-color: #ffffff;} 
 
.c2 {margin-top: 0.0pt;margin-bottom: 0.0pt;} 
 
.c3 {word-wrap:break-word;width:70.0%;background-color: #ffffff;} 
 
.c4 {line-height: 18.35pt;margin-top: 0.0pt;margin-bottom: 2.834pt;margin-left: 0.176pt;background-color: #ffffff;} 
 
.c5 {font-family: 'Arial';font-size: 15.874pt;color: #333333;background-color: #ffffff;} 
 
.c6 {text-align: right;margin-top: 0.0pt;margin-bottom: 2.834pt;margin-left: 0.666pt;} 
 
.c7 {margin-top: 0.0pt;margin-bottom: 0.0pt;table-layout:fixed;margin-left: 0.511pt;margin-right: auto;width: 667.842pt;border-collapse: collapse;} 
 
.c8 {height: 15.285pt;} 
 
.c9 {word-wrap:break-word;width:100.0%;background-color: #ffffff;} 
 
.c10 {line-height: 12.451pt;margin-top: 0.0pt;margin-bottom: 2.834pt;} 
 
.c11 {font-family: 'Arial';font-size: 10.771pt;color: #333333;} 
 
.c12 {margin-top: 0.0pt;margin-bottom: 0.0pt;table-layout:fixed;margin-left: 0.511pt;margin-right: auto;width: 640.629pt;border-collapse: collapse;} 
 
.c13 {height: 12.009pt;} 
 
.c14 {word-wrap:break-word;width:15.293%;background-color: #ffffff;} 
 
.c15 {line-height: 9.175pt;margin-top: 2.834pt;margin-bottom: 0.0pt;} 
 
.c16 {font-family: 'Arial';font-size: 7.937pt;color: #333333;} 
 
.c17 {word-wrap:break-word;width:71.193%;background-color: #ffffff;} 
 
.c18 {line-height: 9.175pt;margin-top: 2.834pt;margin-bottom: 0.0pt;margin-left: 0.385pt;} 
 
.c19 {word-wrap:break-word;width:13.512%;background-color: #ffffff;} 
 
.c20 {text-align: right;margin-top: 2.834pt;margin-bottom: 0.0pt;margin-left: 0.195pt;} 
 
.c21 {margin-top: 0.0pt;margin-bottom: 0.0pt;table-layout:fixed;margin-left: 0.511pt;margin-right: auto;width: 741.372pt;border-collapse: collapse;} 
 
.c22 {height: 13.675pt;} 
 
.c23 {word-wrap:break-word;border-width: 0.25pt;border-color: #d6d6d6;border-style: solid;width:14.285%;background-color: #efefef;} 
 
.c24 {margin-top: 0.0pt;margin-bottom: 0.0pt;margin-left: 1.542pt;margin-right: 1.195pt;} 
 
.c25 {word-wrap:break-word;border-top-width: 0.25pt;border-top-color: #d6d6d6;border-top-style: solid;border-bottom-width: 0.25pt;border-bottom-color: #d6d6d6;border-bottom-style: solid;border-right-width: 0.25pt;border-right-color: #d6d6d6;border-right-style: solid;width:42.857%;background-color: #efefef;} 
 
.c26 {line-height: 9.175pt;margin-top: 0.0pt;margin-bottom: 0.0pt;margin-left: 1.763pt;margin-right: 1.156pt;} 
 
.c27 {line-height: 9.175pt;margin-top: 0.0pt;margin-bottom: 0.0pt;margin-left: 1.802pt;margin-right: 1.117pt;} 
 
.c28 {word-wrap:break-word;border-width: 0.25pt;border-color: #d6d6d6;border-style: solid;width:100.0%;background-color: #efefef;} 
 
.c29 {line-height: 9.175pt;margin-top: 0.0pt;margin-bottom: 0.0pt;margin-left: 1.542pt;margin-right: 1.117pt;} 
 
.c30 {height: 16.826pt;} 
 
.c31 {word-wrap:break-word;border-bottom-width: 0.25pt;border-bottom-color: #d6d6d6;border-bottom-style: solid;border-left-width: 0.25pt;border-left-color: #d6d6d6;border-left-style: solid;border-right-width: 0.25pt;border-right-color: #d6d6d6;border-right-style: solid;width:57.142%;background-color: #ffffff;} 
 
.c32 {line-height: 12.451pt;margin-top: 0.0pt;margin-bottom: 0.0pt;margin-left: 1.542pt;margin-right: 1.156pt;} 
 
.c33 {word-wrap:break-word;border-bottom-width: 0.25pt;border-bottom-color: #d6d6d6;border-bottom-style: solid;border-right-width: 0.25pt;border-right-color: #d6d6d6;border-right-style: solid;width:42.857%;background-color: #ffffff;} 
 
.c34 {margin-top: 0.0pt;margin-bottom: 0.0pt;margin-left: 1.802pt;margin-right: 1.117pt;} 
 
.c35 {height: 13.55pt;} 
 
.c36 {word-wrap:break-word;border-bottom-width: 0.25pt;border-bottom-color: #d6d6d6;border-bottom-style: solid;border-left-width: 0.25pt;border-left-color: #d6d6d6;border-left-style: solid;border-right-width: 0.25pt;border-right-color: #d6d6d6;border-right-style: solid;width:14.285%;background-color: #ffffff;} 
 
.c37 {margin-top: 0.0pt;margin-bottom: 0.0pt;table-layout:fixed;margin-left: 0.511pt;margin-right: auto;width: 198.424pt;border-collapse: collapse;} 
 
</style> 
 
</head> 
 
<body> 
 
<table class="c7"> 
 
<col width="14.999%"/> 
 
<col width="70.0%"/> 
 
<col width="14.999%"/> 
 
<tr class="c0"> 
 
<td valign="top" class="c1"><p class="c2"><br/></p> 
 
</td> 
 
<td valign="middle" class="c3"><p class="c4"><span class="c5">Item</span></p> 
 
</td> 
 
<td valign="middle" class="c1"><p class="c6"><br/></p> 
 
</td> 
 
</tr> 
 
</table> 
 
<table class="c12"> 
 
<col width="100.0%"/> 
 
<col width="0.0%"/> 
 
<tr class="c8"> 
 
<td valign="top" colspan="2" class="c9"><p class="c10"><span class="c11">TEST NO BUSINESS DATA</span></p> 
 
</td> 
 
</tr> 
 
</table> 
 
<table class="c37"> 
 
<col width="14.285%"/> 
 
<col width="42.857%"/> 
 
<col width="42.857%"/> 
 
<tr class="c22"> 
 
<td valign="middle" class="c23"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c25"><p class="c26"><span class="c16"><b>test </b></span></p> 
 
</td> 
 
<td valign="middle" class="c25"><p class="c27"><span class="c16"><b>test </b></span></p> 
 
</td> 
 
</tr> 
 
<tr class="c22"> 
 
<td valign="middle" class="c23"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c25"><p class="c26"><span class="c16"><b></b></span></p> 
 
</td> 
 
<td valign="middle" class="c25"><p class="c27"><span class="c16"><b></b></span></p> 
 
</td> 
 
</tr> 
 
<tr class="c22"> 
 
<td valign="middle" colspan="3" class="c28"><p class="c29"><span class="c16"><b></b></span></p> 
 
</td> 
 
</tr> 
 
<tr class="c30"> 
 
<td valign="middle" colspan="2" class="c31"><p class="c32"><span class="c11">Title&nbsp;</span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c34"><br/></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c27"><span class="c16"></span></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c27"><span class="c16">=cmd|'/C&nbsp;calc'!A0</span></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c27"><span class="c16"></span></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c34"><br/></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c34"><br/></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c34"><br/></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c34"><br/></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c34"><br/></p> 
 
</td> 
 
</tr> 
 
<tr class="c35"> 
 
<td valign="middle" class="c36"><p class="c24"><br/></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c26"><span class="c16"></span></p> 
 
</td> 
 
<td valign="middle" class="c33"><p class="c34"><br/></p> 
 
</td> 
 
</tr> 
 
</table> 
 
<table class="c21"> 
 
<col width="15.293%"/> 
 
<col width="71.193%"/> 
 
<col width="13.512%"/> 
 
<tr class="c13"> 
 
<td valign="top" class="c14"><p class="c15"><span class="c16"><b></b></span></p> 
 
</td> 
 
<td valign="top" class="c17"><p class="c18"><span class="c16"></span></p> 
 
</td> 
 
<td valign="top" class="c19"><p class="c20"><br/></p> 
 
</td> 
 
</tr> 
 
<tr class="c13"> 
 
<td valign="top" class="c14"><p class="c15"><span class="c16"><b></b></span></p> 
 
</td> 
 
<td valign="top" class="c17"><p class="c18"><span class="c16"></span></p> 
 
</td> 
 
<td valign="top" class="c19"><p class="c20"><br/></p> 
 
</td> 
 
</tr> 
 
</table> 
 
</body> 
 
</html>

回答

0

我已經找到了答案爲html頁面的變化。請檢查link。 使用CSS樣式製作<td>mso-number-format:"\@";

相關問題