如何使用yii框架

时间:2017-07-27 01:34:51

标签: php excel yii powerpoint

我有预览powerpoint演示文稿或excel文件的项目。这是我的代码

    <?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
if (count($dataJadwal) > 0) {
// get a reference to the path of PHPExcel classes
    $phpExcelPath = Yii::getPathOfAlias('ext.phpexcel.Classes.PHPExcel');

// Turn off our amazing library autoload
    spl_autoload_unregister(array('YiiBase', 'autoload'));
    Yii::import('ext.phpexcel.Classes.PHPExcel', true);
    spl_autoload_register(array('YiiBase', 'autoload'));
//
// making use of our reference, include the main class
// when we do this, phpExcel has its own autoload registration
// procedure (PHPExcel_Autoloader::Register();)
    include($phpExcelPath . DIRECTORY_SEPARATOR . 'IOFactory.php');

//require_once("D:\server/www/cls/PHPExcel.php");
//require_once("D:\server/www/cls/PHPExcel/IOFactory.php");
    $objPHPExcel = PHPExcel_IOFactory::load(urldecode($dataJadwal[0]['fileJadwal']));

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
//$objWriter->save('example.html');
$objWriter->writeAllSheets();
    $objWriter->save('php://output');

    Yii::app()->clientScript->registerScript('cje', "$('table').addClass('table table-bordered table-condensed table-hover')");
} else {
    ?>
   <div class="alert alert-danger" style="width: 50%; font-size: 32px; margin: 0 auto; margin-top: 20%; text-align: center"><i class="fa fa-3x fa-warning"></i>Tidak ada data.</div>
    <?php
}
?>

我不知道如何获取已上传的扩展文件,如果扩展名为excel文件而不是代码运行phpexcel插件,但如果扩展名为powerpoint文件,则代码将运行插件phppowerpoint。

这是我的表enter image description here

0 个答案:

没有答案