我正在尝试将数据从MySQL导出到xlsx,但是在我的数据库中可能会有一些0和1而不是实际数据。让我更好地解释一下:有一个列用于设置白天还是晚上,但白天使用0,夜晚使用1。当我使用下面的代码导出时,我得到一个带有这些0和1的xlsx。
已经尝试过的东西,例如https://phppot.com/php/database-data-export-to-excel-file-using-php/和https://artisansweb.net/how-to-export-mysql-database-data -to-excel-using-php /但在发送之前我无法编辑xlsx的内容
$filename = "Export_excel.xls";
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=\"$filename\"");
$isPrintHeader = false;
if (! empty($productResult)) {
foreach ($productResult as $row) {
if (! $isPrintHeader) {
echo implode("\t", array_keys($row)) . "\n";
$isPrintHeader = true;
}
echo implode("\t", array_values($row)) . "\n";
}
}
当代码看到零时,我想将其设置为“ day”
holdtom
慕码人8056858