| 发表于:2007-05-12 12:53:005楼 得分:0 |
function topcmexcel() { var myexcel,mybook; myexcel = new activexobject( "excel.application "); if(myexcel!=null){ document.EXECcommand( 'selectall '); document.EXECcommand( 'copy '); document.EXECcommand( 'unselect '); myexcel.visible = true; mybook = myexcel.workbooks.add(); mybook.sheets(1).paste } } 如果不想选择全部文本,可以把document.EXECcommand( 'selectall ');替换为 var sel=document.body.createtextrange(); sel.movetoelementtext(reportdiv); sel.select(); ================== 其中reportdiv为要选择的内容,如: <div id= "reportdiv "> <table> <tr> ..... </table> <div> .... </div> </div> | | |
|