I am currently working on a method to export tabular data from an HTML page to Excel using DocRaptor. My approach involves using PHP to pass the necessary data through their API for conversion into an Excel Spreadsheet.
However, I have encountered an issue where I am unable to pass the entire table structure, including the opening <table>
and closing </table>
tags.
For example, consider the following HTML table:
<table id="placement-table">
<tr id="row">
<td id="cell">Text1</td>
</tr>
<tr id="row1">
<td id="cell">Text2</td>
</tr>
<tr id="row2">
<td id="cell">Text3</td>
</tr>
<tr id="row3">
<td id="cell">Text4</td>
</tr>
</table>
If I use
console.log($('#placement-table').html());
, the output retrieved is as follows:
<tbody><tr id="row">
<td id="cell">Text1</td>
</tr>
<tr id="row1">
<td id="cell">Text2</td>
</tr><tr id="row2">
<td id="cell">Text3</td>
</tr><tr id="row3">
<td id="cell">Text4</td>
</tr>
</tbody>
This missing table tags discrepancy raises questions about whether .html()
function only retrieves content within the specific element. While my objective was to examine passed information in the Console, this observation of missing tags prompted me to seek clarification.
If this explanation is unclear, please let me know so I can update accordingly!