Jak wyeksportować tabelę html do excela lub pdf w php

Na mojej stronie php mam tabelę i jeśli użytkownik wymaga, musi wyeksportować tę tabelę do arkusza Excela.

Kod do wyświetlania tabeli to:

    $sql=mysql_query("SELECT * FROM attendance WHERE (year = '" . mysql_real_escape_string($_SESSION['year']) . "') and ( branch= '" . mysql_real_escape_string(($_SESSION['branch'])). "') and ( sem= '" . mysql_real_escape_string(($_SESSION['sem'])). "') and (sec= '" . mysql_real_escape_string(($_SESSION['sec'])). "')"); print "<body background='bg.jpg'>"; Print "<br><br><BR><center><table border cellpadding=3><tr><th>idno</th><th>name</th><th>subject</th><th>Held Classes</th><th>Attended Classes</th></tr>"; while($data=mysql_fetch_array( $sql ))   { 

    echo "<tr><td>".$data['idno']." </td><td>".$data['name'] . " <td>".$data['subject']." </td><td>".$data['heldcls'] . "<td>".$data['attendcls']." </td>"; } 
 Print "</table><br><br><form action = excel.php method = POST><input type = 'submit' name = 'submit' Value = 'Export to excel'></form></center>";

jak wyeksportować tę tabelę do arkusza Excela. A co powinien b kod wexcel.php. Proszę mi pomóc .. z góry dziękuję ..

questionAnswers(4)

yourAnswerToTheQuestion