JavaScript 弹出询问窗口
var returnValue=showModalDialog("../zlfx/fx_getbglx.jsp",null,"dialogWidth:350px;dialogHeight:150px;center:yes;help:no;status:no;scroll:no");
if(returnValue=="word"){
copyTableToWord(tableid);
}
if(returnValue=="excel"){
copyTableToExcel(tableid);
}
//导出非列表的word 参数tableId为要导出的数据所在的tableid
function copyTableToWord(tableId)
{
var elTable = document.getElementById(tableId);
var sel = document.body.createTextRange();
sel.moveToElementText(elTable); //tab 为导出数据所在的表格ID
//sel.select();
sel.execCommand("Copy");
var oWD = new ActiveXObject("Word.Application");
var oDC = oWD.Documents.Add("",0,1);
var oRange =oDC.Range(0,1);
oRange.Paste();
oWD.Application.Visible = true;
}
//导出非列表的excel 参数tableId为要导出的数据所在的tableid
function copyTableToExcel(tableId){
var elTable = document.getElementById(tableId); //要导出的table id。
//alert(elTable.innerHTML);
var oRangeRef = document.body.createTextRange();
oRangeRef.moveToElementText(elTable);
oRangeRef.execCommand("Copy");
var appExcel = new ActiveXObject("Excel.Application");
appExcel.Workbooks.Add().Worksheets.Item(1).Paste();
appExcel.Visible = true;
appExcel = null;
}