我已经按照php电子表格的要求加载了所有内容,但是当我运行代码时,它只是保持沉默,什么也没有发生
此处带有以下代码https://payme.nouveta.co.ke/api/index.php?function=getReports的链接getReports
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');
我只想下载样本,然后从那里进行下载。我曾经使用composer将供应商文件添加到我的项目中,但是当我运行时却什么也没发生
C:\xampp\htdocs\nouveta\STKPUSH>composer require phpoffice/phpspreadsheet
PHP: syntax error, unexpected '(' in C:\xampp\php\php.ini on line 1052
Using version ^1.6 for phpoffice/phpspreadsheet
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
- Installing markbaker/matrix (1.1.4): Loading from cache
- Installing markbaker/complex (1.4.7): Loading from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing phpoffice/phpspreadsheet (1.6.0): Loading from cache
phpoffice/phpspreadsheet suggests installing mpdf/mpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing dompdf/dompdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing tecnickcom/tcpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing jpgraph/jpgraph (Option for rendering charts, or including charts with PDF or HTML Writers)
Writing lock file
Generating autoload files
C:\xampp\htdocs\nouveta\STKPUSH>
答案 0 :(得分:0)
我看不到下载代码。此$writer->save('hello world.xlsx');
将文件保存在公用文件夹中。可能在那里。
只需提供文件路径作为URL即可下载。 您也可以使用下面的代码下载它。
<?php header("Location: http://example.com/somFile.xlsx"); ?>