欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php ExcelReader 读取Excel类

程序员文章站 2022-05-15 08:10:09
...
这是一款开源的php代码,ExcelReader是专业地excel表进行读写操作的,下面我们来看一款ExcelReader读取phprm.com.xls工作表实例吧,代码如下:
setoutputencoding('cpa25a');
$data->read($file_to_include);
error_reporting(e_all ^ e_notice);
echo " 
 
";
function make_alpha_from_numbers($number) {
    $numeric = "abcdefghijklmnopqrstuvwxyz";
    if ($number  
var sheet_html = array(); ";
for ($sheet = 0; $sheet sheets); $sheet++) {
    $table_output[$sheet].= "
"; for ($i = 0; $i sheets[$sheet]['numcols'] && ($i " . make_alpha_from_numbers($i) . ""; } for ($row = 1; $row sheets[$sheet]['numrows'] && ($row "; for ($col = 1; $col sheets[$sheet]['numcols'] && ($col sheets[$sheet]['cellsinfo'][$row][$col]['colspan'] >= 1 && $data->sheets[$sheet]['cellsinfo'][$row][$col]['rowspan'] >= 1) { $this_cell_colspan = " colspan=" . $data->sheets[$sheet]['cellsinfo'][$row][$col]['colspan']; $this_cell_rowspan = " rowspan=" . $data->sheets[$sheet]['cellsinfo'][$row][$col]['rowspan']; for ($i = 1; $i sheets[$sheet]['cellsinfo'][$row][$col]['colspan']; $i++) { $data->sheets[$sheet]['cellsinfo'][$row][$col + $i]['dontprint'] = 1; } for ($i = 1; $i sheets[$sheet]['cellsinfo'][$row][$col]['rowspan']; $i++) { for ($j = 0; $j sheets[$sheet]['cellsinfo'][$row][$col]['colspan']; $j++) { $data->sheets[$sheet]['cellsinfo'][$row + $i][$col + $j]['dontprint'] = 1; } } } else if ($data->sheets[$sheet]['cellsinfo'][$row][$col]['colspan'] >= 1) { $this_cell_colspan = " colspan=" . $data->sheets[$sheet]['cellsinfo'][$row][$col]['colspan']; $this_cell_rowspan = ""; for ($i = 1; $i sheets[$sheet]['cellsinfo'][$row][$col]['colspan']; $i++) { $data->sheets[$sheet]['cellsinfo'][$row][$col + $i]['dontprint'] = 1; } } else if ($data->sheets[$sheet]['cellsinfo'][$row][$col]['rowspan'] >= 1) { $this_cell_colspan = ""; $this_cell_rowspan = " rowspan=" . $data->sheets[$sheet]['cellsinfo'][$row][$col]['rowspan']; for ($i = 1; $i sheets[$sheet]['cellsinfo'][$row][$col]['rowspan']; $i++) { $data->sheets[$sheet]['cellsinfo'][$row + $i][$col]['dontprint'] = 1; } } else { $this_cell_colspan = ""; $this_cell_rowspan = ""; } if (!($data->sheets[$sheet]['cellsinfo'][$row][$col]['dontprint'])) { $table_output[$sheet].= ""; } } $table_output[$sheet].= ""; } $table_output[$sheet].= "
" . $row . " "; if ($force_nobr) { $table_output[$sheet].= ""; } $table_output[$sheet].= nl2br(htmlentities($data->sheets[$sheet]['cells'][$row][$col])); if ($force_nobr) { $table_output[$sheet].= ""; } $table_output[$sheet].= "
"; $table_output[$sheet] = str_replace(" ", "", $table_output[$sheet]); $table_output[$sheet] = str_replace(" ", "", $table_output[$sheet]); $table_output[$sheet] = str_replace(" ", " ", $table_output[$sheet]); if ($debug) { $debug_output = print_r($data->sheets[$sheet], true); $debug_output = str_replace(" ", "n", $debug_output); $debug_output = str_replace(" ", "r", $debug_output); $table_output[$sheet].= "
$debug_output
"; } echo "sheet_html[$sheet] = "$table_output[$sheet]"; "; } echo " function change_tabs(sheet) { //alert('sheet_tab_' + sheet); for(i=0;isheets) , ";i++) { document.getelementbyid('sheet_tab_' + i).classname = 'tab_base'; } document.getelementbyid('table_loader_div').innerhtml=sheet_html[sheet]; document.getelementbyid('sheet_tab_' + sheet).classname = 'tab_loaded'; } "; echo " "; for ($sheet = 0; $sheet sheets); $sheet++) { echo ""; } echo ""; echo "
", $data->boundsheets[$sheet]['name'], "
www.phprm.com
"; //echo ""; /* echo "
"; 
print_r($data); 
echo "
"; */

excelreader这个类你可以到官网去下载 .