The followingthinkphp frameworkThe tutorial column will introduce to you how thinkphp refers to the PHPExcel class library. I hope it will be helpful to friends in need!
Problem description:
thinkphp3.2.3 How to reference the PHPExcel class library?
Introducing the file directory location
ThinkPHP\Library\Org\Util PHPExce(文件夹) PHPExcel.php
As shown
Method code
public function getExcel() { //导入PHPExcel类库 import("Org.Util.PHPExcel"); import("Org.Util.PHPExcel.Writer.Excel5"); import("Org.Util.PHPExcel.IOFactory.php"); //创建PHPExcel对象 $objPHPExcel = new \PHPExcel(); }
Then I executed the program and it said that the class library does not exist
Problem analysis and methods:
It is not recommended to use third-party class libraries Place it under Org\Util. Thinkphp specially provides the function of importing third-party class libraries. Directly put your PHPExcel under the directory vendor (ThinkPHPLibraryVendor),
When using Use the vendor method to import
//相当于引入了vemdor目录下面PHPExcel\PHPExcel.php vendor('PHPExcel.PHPExcel'); $x = new \PHPExcel(); //vendor('PHPExcel.PHPExcel'); //vendor('PHPExcel.PHPExcel.Writer.Excel5'); //vendor('PHPExcel.PHPExcel.IOFactory.php');
Recommended: "The latest 10 thinkphp video tutorials"
The above is the detailed content of An article explaining how thinkphp refers to the PHPExcel class library. For more information, please follow other related articles on the PHP Chinese website!