search
HomePHP FrameworkThinkPHPAn article explaining how thinkphp refers to the PHPExcel class library

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

An article explaining how thinkphp refers to the PHPExcel class library

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();
    }

An article explaining how thinkphp refers to the PHPExcel class library

Then I executed the program and it said that the class library does not exist

An article explaining how thinkphp refers to the PHPExcel class library

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),

An article explaining how thinkphp refers to the PHPExcel class library

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!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software