Set Filename for Excel Support
Set Filename for Excel Support

Hello together
We use Data Tables latest Version and everything is working fine except the following. How can we set a custom File Name to the Exported Excel File
Below the Code of the Datatable Call:
```<?php
include '../includes/head1.php';
$currentPage = 'bulkdig';
$nameservers?>
<body>
<?php
require '../includes/nav.php';
Bulk DIG Tool
<
div class="container center">
<?php
if (isset($_POST['domains'])) {
$idn_domain = $_POST['domains'];
$domain = $idn_domain;
$domain = explode("\r\n", $domain);
$domain = preg_replace('/\s+/', '', $domain);
printf("<br><br>
<
table class='table table-hover table-bordered'>\n");
printf("<br><br>
<
table id='domains' class='table table-striped table-bordered nowrap'>\n");
printf(" <thead>\n");
printf(" <tr>\n");
printf(" <td>Domain</td>\n");
printf(" <td>ohne www</td>\n");
printf(" <td>www</td>\n");
printf(" <td>MX IP</td>\n");
printf(" <td>MX Eintrag</td>\n");
printf(" </tr>\n");
printf(" </thead>\n");
printf(" <tbody>\n");
foreach ($domain as $entry) {
$entry = idn_to_ascii($entry);
$a_record = dns_get_record($entry, DNS_A);
$www = dns_get_record("www." . $entry, DNS_ANY);
$mx = dns_get_record($entry, DNS_MX);
printf(" <tr>\n");
printf(" <td>%s</td>", $entry);
printf(" <td>");
foreach ($a_record as $arr) {
echo $arr['ip'];
}
printf(" </td>");
printf(" <td>");
foreach ($www as $arrwww) {
if ($arrwww["type"] == "CNAME") {
$cname = $arrwww["target"];
$cname = dns_get_record($cname, DNS_A);
foreach ($a_record as $arrcname) {
echo $arrcname["ip"], "<br>";
}
echo "(" . $arrwww["target"], ")";
} else {
echo $arrwww["ip"];
}
}
printf(" </td>");
printf(" <td>");
foreach ($mx as $arrmx) {
$mx1 = $arrmx['target'];
$mx1 = gethostbyname($mx1);
echo $mx1, " <br>";
}
printf(" </td>");
printf(" <td>");
foreach ($mx as $arrmx) {
echo $arrmx['target'], " <br>";
}
printf(" </td>");
}
printf(" </tr>\n");
$domain = strtok("\n");
}
<?php > <!-- added search and scrollbar when more Entrys ?>$(document).ready(function() {
$('#domains').DataTable( {
dom: 'Bfrtip',
scrollY: '50vh',
scrollCollapse: true,
"paging": false,
"info" : false,
"order": [],
"searching": true,
buttons: [
'copyHtml5', 'csvHtml5', 'excelHtml5',
]
} );
} );
</script>
```
Replies
Use
filename
, see example here.Colin
Hello Colin
Thanks for your help. This worked perfectly