Class' PHPExcel_Worksheet'未找到

时间:2017-07-10 03:43:34

标签: php phpexcel

这是我第一次使用PHPexcel,我在编译代码时遇到了一些麻烦,给我一个错误: Class' PHPExcel_Worksheet'在第371行的C:\ xampp \ htdocs \ sampleexcel \ Classes \ PHPExcel.php中找不到

我在网上查了一下,发现自动装弹机有问题吗?

我想要做的是从我的数据库中获取数据并将其导出为具有多个工作表的excel文件。

您能帮助我调试此代码或向我提供有关如何修复自动加载器的提示吗?

这是我的索引php代码:

   if (function_exists('__autoload')) {
    //    Register any existing autoloader function with SPL, so we don't 
  get any clashes
    spl_autoload_register('__autoload');
}
//    Register ourselves with SPL
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));

  include 'config.php'; 
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';

// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Create a first sheet, representing sales data
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Something');

// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle('Name of Sheet 1');

// Create a new worksheet, after the default sheet
$objPHPExcel->createSheet();

// Add some data to the second sheet, resembling some different data types
$objPHPExcel->setActiveSheetIndex(1);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'More data');

// Rename 2nd sheet
$objPHPExcel->getActiveSheet()->setTitle('Second sheet');

// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="sample.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

$objWriter->save('php://output');

这是我的config.php代码:

<?php


    $server = "localhost";
    $db_uname = "root";
    $db_passwd = "";
    $db = "svr";

    $connect = mysqli_connect("localhost", "root", "", "svr") or  die("Could not connect: " .mysqli_error($connect));

?>

0 个答案:

没有答案