Fail Export table to excel
Fail Export table to excel
armstronge
Posts: 10Questions: 2Answers: 0
Can someone help me, i've got table with 3 row data . when i try to export that table into excel it just appear in one row data . i dont know what is the problem i try to turn of the select function but nothing change at all. Please help me.
nb: Sorry for my bad english
<script type="text/javascript">
$(document).ready(function() {
$('#tableViewKuota').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
} );
} );
</script>
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @armstronge ,
I'm guessing an error occurred that interrupted the export - is there anything in the console? We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
here's the running test case, and i thing i've got no issue in the console https://jsbin.com/hohomabuma/edit?html,console,output
Thank you for the link. Can you show us the rendered HTML please (i.e. "View source")? The PHP code you've embedded there isn't going to execute, so we'd need to see what the generated HTML is.
Allan
Here's the rendered HTML http://live.datatables.net/tipaqede/1/edit
At the end of every row in the body you have:
So the HTML being used isn't valid.
If you change it so that the closing
tbody
tag is pesent only after all the body rows it should work as expected.Allan
Dear @allan ,
thx for your response. But i'm kinda confused, because in my html table tag i dont have <br>. Can you show me the right tag using commnent in this
rendered HTML 'viewsource' http://live.datatables.net/tipaqede/1/edit
What Allan said is you have
</tbody>
at the end of each for, for example:End of row 1:
End of row 2:
Then the last row:
You should have only one
</tbody>
at the end of your rows.Kevin
hello @kthorngren,
thx for your responds, now i know what is the problem. But can you give me a clue how to disable auto tag <tbody> when i catching array data from database phpmyadmin because <tbody> tag is auto regenerate based on query i have in phpmyadmin
'''
<tbody>
<?php
include("Db_kuota.php");
$run=mysqli_query($dbkuota,"SELECT Nama_Univ, Nama_Stase,
Sept1, Sept2, Sept3, Sept4,
Okt1, Okt2, Okt3, Okt4,
Nov1, Nov2, Nov3, Nov4, Nov5,
Des1, Des2, Des3, Des4,
Jan1, Jan2, Jan3, Jan4,
Feb1, Feb2, Feb3, Feb4, Feb5,
Mar1, Mar2, Mar3, Mar4,
Apr1, Apr2, Apr3, Apr4,
Mei1, Mei2, Mei3, Mei4, Mei5,
Jun1, Jun2, Jun3, Jun4,
Jul1, Jul2, Jul3, Jul4,
Agt1, Agt2, Agt3, Agt4, Agt5
FROM book_kuota
INNER JOIN universitas ON book_kuota.Id_Univ = universitas.Id_Univ
INNER JOIN stase ON book_kuota.Id_Stase = stase.Id_Stase
WHERE book_kuota.Id_Stase='1'");//here run the sql query.
'''
here the source code of the php inside <tbody> tag http://live.datatables.net/tipaqede/4/edit
You've got the
tbody
closing tag inside the loop for the body row output. Move it outside of the loop.Allan
Dear allan, kthorngren, and colin.
Thanks for your help