1、首先將網(wǎng)站的地址加入受信任的站點
2、在"工具-internet選項-安全-受信任的站點"中點“自定義級別”,在“對沒有標注安全的Acitvex控件進行初始化和腳本運行”中點選“禁止”或“啟用”,就ok了。
如何取office版本號、安裝路徑和使用者
alert("您的" + wrd.Application.Caption + "安裝路徑為: " + wrd.Application.Path + " 版本號是:" + wrd.Application.version
+ " 注冊使//用者是:" + wrd.Application.UserName)
--------------------------------------------------------------------------------
javascript將網(wǎng)頁表格導(dǎo)出Word
<script>
function AllAreaWord()
{
if(document.all("tab").rows.length==0)
{
alert("沒有內(nèi)容可導(dǎo)!");
return;
}
try{
var oWD = new ActiveXObject("Word.Application");
}catch(e)
{
alert("無法調(diào)用Office對象,請確保您的機器已安裝了Office并已將本系統(tǒng)的站點名加入到IE的信任站點列表中!");
return;
}
var oDC = oWD.Documents.Add("",0,1);
var oRange =oDC.Range(0,1);
var sel = document.body.createTextRange();
sel.moveToElementText(tab); //tab 為導(dǎo)出數(shù)據(jù)所在的表格ID
sel.select();
sel.execCommand("Copy");
oRange.Paste();
oWD.Application.Visible = true;
}
</script>
<table id="tab" align="center" width="300" border="1" bordercolor="#2baeff" cellpadding="0" cellspacing="0" bgcolor="lightblue">
<Tr>
<Td>1</td>
<Td>2</td>
<Td>3</td>
</tr>
<Tr>
<Td>4</td>
<Td>5</td>
<Td>6</td>
</tr>
<Tr>
<Td>7</td>
<Td>8</td>
<Td>9</td>
</tr>
</table>
<input type=button name='button_export' title="導(dǎo)出到word" onclick=AllAreaWord() value=下載到word>
--------------------------------------------------------------------------------
javascript將網(wǎng)頁表格導(dǎo)出Excel
<SCRIPT LANGUAGE="javascript">
<!--
function AutomateExcel()
{
var elTable = document.getElementById("outtable"); //outtable 為導(dǎo)出數(shù)據(jù)所在的表格ID;
var oRangeRef = document.body.createTextRange();
oRangeRef.moveToElementText( elTable );
oRangeRef.execCommand( "Copy" );
try{
var appExcel = new ActiveXObject( "Excel.Application" );
}catch(e)
{
alert("無法調(diào)用Office對象,請確保您的機器已安裝了Office并已將本系統(tǒng)的站點名加入到IE的信任站點列表中!");
return;
}
appExcel.Visible = true;
appExcel.Workbooks.Add().Worksheets.Item(1).Paste();
appExcel = null;
}
//-->
</SCRIPT>
<input type="button" name="out_excel" onClick="AutomateExcel();" value="導(dǎo)出到excel" class="notPrint">
<table border="1" cellpadding="0" cellspacing="0" id=outtable>
<tr height="28">
<td width="27" height="86" rowspan="4" bgcolor="#ffffcc">序號</td>
<td width="111" rowspan="4" bgcolor="#ffffcc"><div align="center">服務(wù)網(wǎng)點</div></td>
<td width="402" colspan="7" bgcolor="#ffffcc"><div align="center">用戶滿意度</div></td>
</tr>
<tr height="19">
<td width="100" height="39" colspan="3" rowspan="2" bgcolor="#ffffcc"><div align="center">樣本數(shù)量</div></td>
<td width="218" colspan="3" rowspan="2" bgcolor="#ffffcc">對該服務(wù)網(wǎng)點實施本次活動的整體評價,滿分10分(平均分數(shù))</td>
<td width="84" rowspan="3" bgcolor="#ffffcc"><div align="center">季度平均分</div></td>
</tr>
<tr height="20"> </tr>
<tr height="19">
<td width="29" height="19" bgcolor="#ffffcc"><div align="center">4月</div></td>
<td width="29" bgcolor="#ffffcc"><div align="center">5月</div></td>
<td width="42" bgcolor="#ffffcc"><div align="center">合計</div></td>
<td width="68" bgcolor="#ffffcc"><div align="center">4月</div></td>
<td width="68" bgcolor="#ffffcc"><div align="center">5月</div></td>
<td width="82" bgcolor="#ffffcc"><div align="center">合計</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td bgcolor="#ffffcc"> </td>
<td> </td>
<td> </td>
<td bgcolor="#ffffcc"> </td>
<td bgcolor="#ffffcc"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td bgcolor="#ffffcc"> </td>
<td> </td>
<td> </td>
<td bgcolor="#ffffcc"> </td>
<td bgcolor="#ffffcc"> </td>
</tr>
</table>