标签:
项目需要读取Excel的内容,从百度搜索了下,主要有两个选择,第一个是PHPExcelReader,另外一个是PHPExcel。
|
1
2
3
4
5
6
|
require_once ‘/libs/PHPExcel-1.8.0/Classes/PHPExcel.php‘; //修改为自己的目录echo ‘<p>TEST PHPExcel 1.8.0: read xlsx file</p>‘;$objReader = PHPExcel_IOFactory::createReaderForFile($filename);$objPHPExcel = $objReader->load($filename);$objPHPExcel->setActiveSheetIndex(1);$date = $objPHPExcel->getActiveSheet()->getCell(‘A16‘)->getValue(); |
1 <table id="table_id">
2 <?php
3 $objWorksheet = $objPHPExcel->getActiveSheet();
4 $i = 0;
5 foreach($objWorksheet->getRowIterator() as $row){
6 ?>
7 <tr>
8 <?php
9 $cellIterator = $row->getCellIterator();
10 $cellIterator->setIterateOnlyExistingCells(false);
11
12 if( $i == 0 ){
13 echo ‘<thead>‘;
14 }
15 foreach($cellIterator as $cell){
16
17 echo ‘<td>‘ . $cell->getValue() . ‘</td>‘;
18
19 }
20 if( $i == 0 ){
21 echo ‘</thead>‘;
22 }
23 $i++;
24 ?>
25 </tr>
26 <?php
27 }
28 ?>
29 </table>
转 http://www.cnblogs.com/cocowool/p/4025852.html
同时也可借鉴这篇文章 http://extjs.org.cn/fatjames/archives/379
标签:
原文地址:http://www.cnblogs.com/likwo/p/4525063.html