phpspreadsheet работает на локальных, но не на живых - PullRequest
0 голосов
/ 11 мая 2018

Я установил phpspreadsheet с композитором в моем проекте Codeigniter.Он работает нормально на локальном компьютере, но выдает ошибку в рабочей среде:

Этот сайт недоступен. Веб-страница на http://www.xxxxxx.com/email/exportemail может быть временно недоступна или она постоянно перемещена вновый веб-адрес.ERR_INVALID_RESPONSE

Мой код:

require(APPPATH . 'vendor/autoload.php');

use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;

class Email extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }
    public function exportemail(){

        $customers = $this->sales_model->getCustomerRows();

        $spreadsheet = new Spreadsheet();
        $spreadsheet->setActiveSheetIndex(0)
                ->setTitle('Location')
                ->setCellValue('A1', 'Customer')
                ->setCellValue('B1', 'Contact name')
                ->setCellValue('C1', 'Managed by')
                ->setCellValue('D1', 'Email');
        foreach($customers as $key => $customers_data) {
            $x = $key + 2;
            $spreadsheet->setActiveSheetIndex(0)
                    ->setCellValue("A$x", $customers_data['cust_pub'])
                    ->setCellValue("B$x", $customers_data['ccd_name'])
                    ->setCellValue("C$x", $customers_data['m_name'])
                    ->setCellValue("D$x", $customers_data['cust_pub_email']);
        }
        $filename = 'Export_Email.xlsx'; //save our workbook as this file name
        // 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');
        // If you're serving to IE 9, then the following may be needed
        header('Cache-Control: max-age=1');

        // If you're serving to IE over SSL, then the following may be needed
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
        header('Pragma: public'); // HTTP/1.0

        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
        $writer->save('php://output');
    }
}

Может кто-нибудь сказать мне, какие изменения необходимо внести в прямом эфире?

...