大家对
PHP导入Excel文件代码示例如下:
- ?php
- require_once '../Excel/reader.php';
- // ExcelFile($filename, $encoding);
- $data = new Spreadsheet_Excel_Reader();
- // Set output Encoding.指定中文码
- $data->setOutputEncoding('gb2312');
- /***
- * if you want you can change '
iconv' to mb_convert_encoding: - * $data->setUTFEncoder('mb');
- **//***
- * By default rows & cols indeces start with 1
- * For change initial index use:
- * $data->setRowColOffset(0);
- **/
- /***
- * Some function for formatting output.
- * $data->setDefaultFormat('%.2f');
- * setDefaultFormat - set format for
columns with unknown formatting - * $data->setColumnFormat(4, '%.3f');
- * setColumnFormat - set format for
column (apply only to number fields) - **/
- // 指定读取的excel文件
- $data->read('../uploads/jsxz01.xls');
- /*
- $data->sheets[0]['numRows'] - count rows
- $data->sheets[0]['numCols'] - count columns
-
$data->sheets[0]['cells'][$i][$j] - data
from $i-row $j-column -
$data->sheets[0]['cellsInfo'][$i][$j] -
extended info about cell -
$data->sheets[0]['cellsInfo'][$i][$j]['type']
= "date" | "number" | "unknown" - if 'type' == "unknown" - use 'raw' value,
because cell contain value with format '0.00'; -
$data->sheets[0]['cellsInfo'][$i][$j]['raw']
= value if cell without format - $data->sheets[0]['cellsInfo'][$i][$j]['colspan']
- $data->sheets[0]['cellsInfo'][$i][$j]['rowspan']
- */
- error_reporting(E_ALL ^ E_NOTICE);
- // 循环读取每一个单元值
-
for ($i = 1; $i = $data->sheets[0]
['numRows']; $i++) { -
for ($j = 1; $j = $data->sheets[0]
['numCols']; $j++) { -
echo """.$data->sheets[0]['cells']
[$i][$j]."","; - }
- echo " br>";
- }
- //print_r($data);
- //print_r($data->formatRecords);
- ?>
希望上面这段PHP导入Excel文件的实现代码可以帮助我们对这一知识点有一个深刻的认识。
Déclaration
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud
R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
3 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Meilleurs paramètres graphiques
3 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Solution d'énigmes de coquille
2 Il y a quelques semainesByDDD
R.E.P.O. Comment réparer l'audio si vous n'entendez personne
3 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Comment déverrouiller tout dans Myrise
4 Il y a quelques semainesBy尊渡假赌尊渡假赌尊渡假赌

Outils chauds

PhpStorm version Mac
Le dernier (2018.2.1) outil de développement intégré PHP professionnel

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Adaptateur de serveur SAP NetWeaver pour Eclipse
Intégrez Eclipse au serveur d'applications SAP NetWeaver.

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

VSCode Windows 64 bits Télécharger
Un éditeur IDE gratuit et puissant lancé par Microsoft