Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

C#
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 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
Posted
Comments
Suk@nta 7-Apr-14 5:33am    
i think you should write a.innerHTML instread of a.outerText

1 solution

C#
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;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900