search
HomeBackend DevelopmentPHP ProblemHow to read data in excel in php

How to read data in excel in php

Sep 24, 2019 pm 01:04 PM
excelphpread

How to read data in excel in php

1. Set up a PHP program running environment to execute the program, as long as the program can run

2. Download PHPExcel. php class files and related components

How to read data in excel in php

3. Include it in the file to be run require PHPExcel.php, create the object by default Use excel2007 to read excel. If the format is incorrect, use the previous version to read

How to read data in excel in php

4. Read excel There can be multiple worksheets. If you only need to read the first one, use $PHPExcel->getSheet(0). If there are multiple worksheets, operate the other contents in a loop

How to read data in excel in php

5. Get the rows and columns of the excel table respectively

$allColumn = $currentSheet->getHighestColumn(); 
/**取得一共有多少行*/ 
$allRow = $currentSheet->getHighestRow(); 
/**从第二行开始输出,因为excel表中第一行为列名*/

How to read data in excel in php

6. Read the corresponding data in a double loop of rows and columns

for($currentRow = 2;$currentRow <= 98;$currentRow++){ 
/**从第A列开始输出*/ 
echo"<tr>";
//for($currentColumn= &#39;A&#39;;$currentColumn<= $allColumn; $currentColumn++){ 
$cancername="";
for($currentColumn= &#39;A&#39;;$currentColumn<=&#39;B&#39;; $currentColumn++){

Two for cross-positioning can read the cell data

How to read data in excel in php

Recommended tutorial: PHP video tutorial

The above is the detailed content of How to read data in excel in php. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools