如何将整个html体复制并粘贴到excel表中 [英] how to copy and paste whole html body into excel sheet

查看:1531
本文介绍了如何将整个html体复制并粘贴到excel表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







function copyFn()
{
debugger;
var yourDOCTYPE = "<!DOCTYPE html>"; // your doctype declaration
var printPreview =  new ActiveXObject("Excel.Application");//window.open('about:blank', 'print_preview', "resizable=yes,scrollbars=yes,status=yes");
 //var ExcelSheet = new ActiveXObject("Excel.Sheet");
var printDocument = new ActiveXObject("Excel.Sheet");
var a = document.getElementById("body1");
printPreview.Worksheets.Add(a.outerText);
}





i希望复制整个html正文并粘贴到excel中,我不知道这是正确的做法或不,上面的代码不起作用



i want to copy whole html body and paste into excel ,i dont know wether this is the right approac to do or not, the above code is not working

推荐答案

function copyFn()

{

//copy innerHTML of YourTable to strCopy Variable.

var strCopy=document.getElementById("head").outerHTML;
//copy strCopy to clipboardData, this

window.clipboardData.setData("Text", strCopy);

var objExcel = new ActiveXObject("Excel.Application");

var objWorkbook = objExcel.Workbooks.Add;

var objWorksheet = objWorkbook.Worksheets(1);
objExcel.visible = true;
objWorksheet.Paste;


这篇关于如何将整个html体复制并粘贴到excel表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆