如何使用新的PhpSpreadsheet与ZF1

uxhixvfz  于 2023-02-15  发布在  PHP
关注(0)|答案(1)|浏览(121)

在PHP 7之前我使用PHPEXcel,现在我使用PHP 7. 4,并且必须在我的Zend Framework 1 Web应用程序中使用PhpSpreadsheet。
这意味着,恕我直言,不要使用Composer,所以我问题很简单:怎么做?
我尝试在我的项目中使用示例,但不起作用

cvxl0en2

cvxl0en21#

我的public/index.php中的代码

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    realpath(APPLICATION_PATH . '/../library/fpdf'),
    realpath(APPLICATION_PATH . '/../library/biffwriter'),  
    realpath(APPLICATION_PATH . '/../library/editablegrid'),
    realpath(APPLICATION_PATH . '/models'),
    realpath(APPLICATION_PATH . '/controllers'),
    realpath(APPLICATION_PATH . '/forms'),  
    get_include_path(),
)));

/* PATH FOR FPDF (FONT)*/
define('FPDF_FONTPATH',APPLICATION_PATH.'/../library/fpdf/font/');

/** Zend_Application */
require_once 'Zend/Application.php';  
require_once 'phpspreadsheet/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

ExportControllers中的代码

* Export content in a XLSx file
     * @return 
     * @param object $content
     * @param object $filename
     */
    public static function exportAsXLSx($content, $filename, $parades, $resultat) 
      {     
        // $objPHPExcel = new PHPExcel();
        
        error_log("Creating Spreadsheet instance");
        $objPHPExcel = new Spreadsheet();
        $sheet = $objPHPExcel->getActiveSheet();
        
        error_log("setting up properties");
        $objPHPExcel->getProperties()->setCreator("Web BASCULE")
                             ->setLastModifiedBy("Web BASCULE")
                             ->setTitle("Extraction des données de WEB bascule")
                             ->setSubject(" ")
                             ->setDescription(" ")
                             ->setKeywords("Bascule ")
                             ->setCategory("Result file");
        
        error_log("setting up FONT");
        $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial')->setSize(10);
        
        error_log("setting up activeSHEET");
        $objPHPExcel->setActiveSheetIndex(0);

        error_log("we are here");

我没有任何文件和我的php-fpm/www-error.log说创建电子表格示例,没有别的...

相关问题