I'm trying to print to excel a query presented in table with php and jquery in the <tbody>
tag. However it did not work. He presented in excel a wrong result with all result HTML in a single cell. COULD YOU HELP ME?
I found the solution on the link
HTML and PHP
<form action="frameworks/teste.php" method="post"
onsubmit='$("#datatodisplay").val( $("<div>").append( $("#minhaTabela").eq(0).clone() ).html() )'>
<table id="minhaTabela" class="table table-striped">
<thead>
<th>DM Clarity</th>
<th>Mantis</th>
<th>Sistema</th>
<th>Descrição</th>
<th>Situação</th>
<th>Prioridade</th>
<th>Previsão Homol.</th>
<th>Ações</th>
</thead>
<tbody>
</tbody>
</table>
<div align="center">
<input type="hidden" id="datatodisplay" name="datatodisplay">
<button type="submit" class="btn btn-primary">Export to Excel</button>
</div>
</form>
<?php
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename=export.xls');
// Fix for crappy IE bug in download.
header("Pragma: ");
header("Cache-Control: ");
echo $_REQUEST['datatodisplay'];
?>