我正在使用 php spreedsheet 处理 excel 文件,我试图提供一个包含数据的数组以在 excel 上下载。
我用ajax做这个请求。这是我的代码。我的代码在 symfony 3.4 上。我尝试使用标题,但是当我单击下载文件时,ajax 请求说好的,但不要给我 excel 文件
$datos = $request->request->get('datos');
$datos = json_decode($datos,true);
$cuenta = count($datos);
$spreadsheet = new Spreadsheet();
$cuentaColumnas = count($datos[0]);
$letra = "a";
$user = $this->getUser()->getUser();
for ($i=0; $i <$cuenta ; $i++) {
$numero = 1;
for ($j=0; $j < $cuentaColumnas ; $j++) {
$informacion = $datos[$i][$j];
$spreadsheet->getActiveSheet()->setCellValue($letra.$numero,$informacion);
$numero++;
}
$letra++;
}
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
// create the writer
$writer = new Xlsx($spreadsheet);
$writer->save();
return $writer;
守候你守候我
FFIVE
随时随地看视频慕课网APP