Table of Contents
php excel reads, phpexcel
Home Backend Development PHP Tutorial php excel reading, phpexcel_PHP tutorial

php excel reading, phpexcel_PHP tutorial

Jul 12, 2016 am 08:52 AM
excel form

php excel reads, phpexcel

Of course, you must first determine whether there is a file and the file type, and then save the file to a certain path

<span>/*</span><span>*
 * 读取excel数据
 * @author Red
 * @date
 * @param $filename 文件所在路径+文件名
 * @param string $encode
 * @param $file_type
 * @return array
 </span><span>*/</span>
<span>function</span> readExcel(<span>$filename</span>, <span>$encode</span> = 'utf-8', <span>$file_type</span><span>)
{
    </span><span>include</span> './plugins/excel/PHPExcel.php'<span>;
    </span><span>include</span> './plugins/excel/PHPExcel/Reader/Excel2007.php'<span>;
    </span><span>include</span> './plugins/excel/PHPExcel/Writer/Excel5.php'<span>;
    </span><span>include</span> './plugins/excel/PHPExcel/Writer/Excel2007.php'<span>;

    </span><span>if</span> (<span>$file_type</span> == 'xlsx'<span>) {
        </span><span>$objReader</span> = PHPExcel_IOFactory::createReader('Excel2007'<span>);
    } </span><span>else</span><span> {
        </span><span>$objReader</span> = PHPExcel_IOFactory::createReader('Excel5'<span>);
    }

    </span><span>$objReader</span>->setReadDataOnly(<span>true</span><span>);

    </span><span>$objPHPExcel</span>        = <span>$objReader</span>->load(<span>$filename</span><span>);
    </span><span>$objWorksheet</span>       = <span>$objPHPExcel</span>-><span>getActiveSheet();
    </span><span>$hightestrow</span>        = <span>$objWorksheet</span>-><span>getHighestRow();
    </span><span>$highestColumn</span>      = <span>$objWorksheet</span>-><span>getHighestColumn();
    </span><span>$highestColumnIndex</span> = PHPExcel_Cell::columnIndexFromString(<span>$highestColumn</span><span>);
    </span><span>$excelData</span>          = <span>array</span><span>();
   //从第二行开始
    </span><span>for</span> (<span>$row</span> = 2; <span>$row</span> <= <span>$hightestrow</span>; <span>$row</span>++<span>) {
        </span><span>for</span> (<span>$col</span> = 0; <span>$col</span> < <span>$highestColumnIndex</span>; <span>$col</span>++<span>) {
            </span><span>$excelData</span>[<span>$row</span>][] = (<span>string</span>)<span>$objWorksheet</span>->getCellByColumnAndRow(<span>$col</span>, <span>$row</span>)-><span>getValue();
        }
    }

    </span><span>return</span> <span>$excelData</span><span>;
}</span>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1125676.htmlTechArticlephp excel reads, phpexcel must first determine whether there is a file and the file type, and then save the file to a certain In the path/* * * Read excel data* @author Red * @date * @param $fi...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What should I do if there is data in the Excel table but the blanks are filtered? What should I do if there is data in the Excel table but the blanks are filtered? Mar 13, 2024 pm 06:38 PM

Excel is a frequently used office software. Many users record various data in the table, but the table clearly contains data and is blank when filtering. Regarding this problem, many users don’t know how to solve it. It doesn’t matter. , the content of this software tutorial is to provide answers to the majority of users. Users in need are welcome to check out the solutions. What should I do if there is data in the Excel table but the blanks are filtered? The first reason is that the table contains blank rows. We want to filter all people with the surname "Li", but we can see that the correct results are not filtered out because the table contains blank rows. How to deal with this situation? Solution: Step 1: Select all content and then filter. Press c

How to convert deepseek pdf How to convert deepseek pdf Feb 19, 2025 pm 05:24 PM

DeepSeek cannot convert files directly to PDF. Depending on the file type, you can use different methods: Common documents (Word, Excel, PowerPoint): Use Microsoft Office, LibreOffice and other software to export as PDF. Image: Save as PDF using image viewer or image processing software. Web pages: Use the browser's "Print into PDF" function or the dedicated web page to PDF tool. Uncommon formats: Find the right converter and convert it to PDF. It is crucial to choose the right tools and develop a plan based on the actual situation.

How to find average in Excel table How to find average in Excel table Aug 07, 2023 am 11:16 AM

How to find the average in an Excel table: 1. Use the AVERAGE function, select a blank cell and enter the function "=AVERAGE", and press the Enter key; 2. Use the SUM function and COUNT function, select a blank cell and enter the function "=SUM/COUNT", press the Enter key; 3. Use the IF function and the AVERAGE function, select a blank cell and enter the function "=AVERAGE, and press the Ctrl+Shift+Enter key combination.

The solution to the problem that Excel tables cannot be filtered The solution to the problem that Excel tables cannot be filtered Mar 14, 2024 am 10:20 AM

In daily life, I find that the Excel table cannot be filtered, what should I do? Excel is one of the most commonly used data processing tools, helping users to complete data entry and organization simply and quickly. In order to allow users to use Excel smoothly, let's take a look at the solutions to the problem that Excel tables cannot be filtered. 1. First open the Excel document and click the [View] option in the menu. 2. Click the [Freeze Window] option in the toolbar. 3. Then in the options that open, cancel the freeze setting. 4. You can re-screen after canceling.

What to do if the Excel table is not fully printed and part of it cannot be printed? What to do if the Excel table is not fully printed and part of it cannot be printed? Mar 20, 2024 pm 10:26 PM

At work, we often print the forms and documents we create into paper versions. Because the form content is too much and too long, sometimes all of it cannot be printed out. What should we do? Next, let’s learn together: excel form printing What to do if an incomplete part cannot be printed. Method/Step 1: First, we need to prepare the form to be printed and adjust it. While maintaining proportions, shorten the horizontal length as much as possible, as shown in the picture. 2. Then we click the &quot;File&quot; button in the upper left corner of the interface, as shown in the picture. 3. Then we click &quot;Print&quot; in the pop-up options, as shown in the picture. 4. After that, the print preview window will pop up, and we click &quot;Print Preview&quot; in it, as shown in the figure. 5. of

How to display two excel tables on the screen at the same time How to display two excel tables on the screen at the same time Mar 20, 2024 pm 01:40 PM

When using data, multiple tables may be involved. The data of several tables must be used back and forth. It is inconvenient to use one table and one window. This requires continuous table switching. If the required data tables can be displayed in one at the same time, On the screen, it saves a lot of time in repeatedly switching tables. Today we will take two tables as an example to see how the editor can magically display them on one screen. The course will begin immediately! In order to realize the function of displaying two tables at the same time, you can create two new Excel tables and name one be TEST1 and the other named TEST2. Open both forms and fill in some content as shown in the image below. 2. Open any table and click the &quot;View&quot; button in the upper toolbar.

How to use deepseek to settle accounts How to use deepseek to settle accounts Feb 19, 2025 pm 04:36 PM

Question: Is DeepSeek available for accounting? Answer: No, it is a data mining and analysis tool that can be used to analyze financial data, but it does not have the accounting record and report generation functions of accounting software. Using DeepSeek to analyze financial data requires writing code to process data with knowledge of data structures, algorithms, and DeepSeek APIs to consider potential problems (e.g. programming knowledge, learning curves, data quality)

How to unlock excel sheet if I forget my password? How to unlock excel sheet if I forget my password? Mar 20, 2024 am 10:19 AM

With the acceleration of the pace of modern life, when there are many passwords set, it is difficult to remember all the passwords. For example, if you forget the password for the Excel table you set, what should you do if you encounter this situation? It’s too much trouble to redo! Next, I will provide you with a solution, come and try it. First, find the password-protected worksheet Excel file, and then change the file name suffix from .xlsx to .rar. This will not have a major impact on the file. If prompted, you can ignore it. 2. Use a compressed file to open the Excel file that you have forgotten the password, and then follow the steps below: xl——worksheets——sheet1.

See all articles