该脚本在本地有效,但是不幸的是,当我将其传输到实时服务器中时,该脚本不再可用。由于共享托管,我的实时服务器没有SSH访问权限。我遇到了一个article,它提供了两个解决方案,但是我更倾向于第二个解决方案(因为我不知道如何应用第一个解决方案,而这在这项技术中还是很新的)。它在本地有效,但不能在实时服务器中使用。 (如图所示)。 我已经解决了一些解决方案,但无济于事。 第二,How to include phpspreadsheet library without composer?
本地,
实时服务器< / strong>,
没有像本地服务器这样的下载选项。
两台计算机上的文件。< br />
本地
实时
< / p>
首先
PHPspreadsheet show blank in browser tab
-该解决方案不适用于我的脚本。
-评论部分提供了一个更简单的解决方案(我已经尝试过,但仍未在实时服务器上下载)[我已经在本地复制了整个文件,并通过FTP将其传输到实时服务器中]
index.php <?php
include 'php/nrgnew.php';
require_once ('vendor/autoload.php');
$count = 2;
$count_mem = 1;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
//$sqlTable = "SELECT * FROM ".$_GET['export_table']." ORDER by name ASC";
$sqlTable = "SELECT * FROM confexhibit ORDER by name ASC";
$sqlTableLoop = mysqli_query($sqlnrg, $sqlTable);
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', '#');
$sheet->setCellValue('B1', 'Name');
$sheet->setCellValue('C1', 'IC');
$sheet->setCellValue('D1', 'Email');
$sheet->setCellValue('E1', 'Phone');
$sheet->setCellValue('F1', 'Member ID');
$sheet->setCellValue('G1', 'Company Name');
$sheet->setCellValue('H1', 'Company Address');
$sheet->setCellValue('I1', 'Company Attention');
$sheet->setCellValue('J1', 'Company Email');
while( $row = mysqli_fetch_array($sqlTableLoop) )
{
$sheet->setCellValue('A'.$count, $count_mem);
$sheet->setCellValue('B'.$count, strtoupper($row['name']));
$sheet->setCellValue('C'.$count, $row['ic']);
$sheet->setCellValue('D'.$count, $row['email']);
$sheet->setCellValue('E'.$count, $row['phone']);
$sheet->setCellValue('F'.$count, $row['id']);
$sheet->setCellValue('G'.$count, $row['companyname']);
$sheet->setCellValue('H'.$count, $row['companyaddress']);
$sheet->setCellValue('I'.$count, $row['companyattention']);
$sheet->setCellValue('J'.$count, $row['companyemail']);
$count++;
$count_mem++;
}
//$filename = $_GET['export_name'].'.xlsx';
$filename = "my_doc.xlsx";
// Redirect output to a client's web browser (Xlsx)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('php://output');