将JSON字符串或数组转换为Excel文件?

How can I convert the array/json into an Excel file (Office Open XML)?

$result = mysql_query($query);
$rows = Array();
while($row = mysql_fetch_assoc($result)) {
    array_push($rows, $row);
}
echo json_encode(Array(
    "data" => $rows
));

For handling office open xml (.xlsx) files you can use PHP-Excel

Tutorials are here

The PHP-Excel has not be maintained for years and must not be used anymore. All users must migrate to its direct successor PhpSpreadsheet
PhpSpreadsheet is the next version of PHPExcel.