1

I have a table in which one td element has an anchor tag inside it for a number.

<td><a href="">213123</a></td>

I am exporting my table data elements to Excel. When the table is exported it is also printing the anchor tag along with the number. Is there a way that I could avoid the anchor tag in Excel sheet and just display the number in the column?

I am using the following code:

function export_to_excel( ptablebody) {

    str="";
    var ExcelApp = new ActiveXObject("Excel.Application");
    var ExcelSheet = new ActiveXObject("Excel.Sheet");
    ExcelSheet.Application.Visible = true;

    var myTableHead = document.getElementById(ptablebody);
    var rowCount = myTableHead.rows.length;

    var colCount = myTableHead.getElementsByTagName("tr")[0].getElementsByTagName("td").length; 

    for(var i=0; i<rowCount; i++) {   
        for(var j=0; j<colCount; j++) {           
            str= myTableHead.getElementsByTagName("tr")[i].getElementsByTagName("td")[j].innerHTML;
            ExcelSheet.ActiveSheet.Cells(i+1,j+1).Value = str;
        }
    }
}
2
  • How are you exporting? Commented Jul 5, 2011 at 8:15
  • @nivas I modified my post with the code i am using. Commented Jul 5, 2011 at 8:36

1 Answer 1

1

I think you want innerText (or on firefox textContent) instead of innerHtml

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.