// print cell data
print "<td class="";
$data = $ws['cell'][$i][$j];
$font = $ws['cell'][$i][$j]['font'];
$style = " style ='".ExcelFont::ExcelToCSS($exc->fonts[$font])."'";
switch ($data['type']) {
// string
case 0:
print "dt_string"".$style.">";
$ind = $data['data'];
if( $exc->sst['unicode'][$ind] ) {
$s = uc2html($exc->sst['data'][$ind]);
} else
$s = $exc->sst['data'][$ind];
if( strlen(trim($s))==0 )
print " ";
else
print $s;
break;
// integer number
case 1:
print "dt_int"".$style."> ";
print $data['data'];
break;
// float number
case 2:
print "dt_float"".$style."> ";
echo $data['data'];
break;
// date
case 3:
print "dt_date"".$style."> ";
$ret = $data[data];//str_replace ( " 00:00:00", "", gmdate("d-m-Y H:i:s",$exc->xls2tstamp($data[data])) );
echo ( $ret );
break;
default:
print "dt_unknown"".$style."> ";
break;
}
print "</td>n";
} else {
print "<td class=empty> </td>n";
}
}
} else {
// print an empty row
for( $j=0; $j<=$ws['max_col']; $j++ )
print "<td class=empty> </td>";
print "n";
}
print "</tr>n";
}
echo "</table><br>n";
} else {
// emtpty worksheet
print "<b> - empty</b><br>n";
}
print "<br>";
}
echo("<input type='submit' name='Submit' value='转换' />");
echo("</form>");
/* print "Formats<br>";
foreach($exc->format as $value) {
printf("( %x )",array_search($value,$exc->format));
print htmlentities($value,ENT_QUOTES);
print "<br>";
}
print "XFs<br>";
for( $i=0;$i<count($exc->xf['format']);$i++) {
printf ("(%x)",$i);
printf (" format (%x) font (%x)",$exc->xf['format'][$i],$exc->xf['font'][$i]);
print "<br>";
}
*/
}
运行效果如下:

第二步是要读取数据出来,
if ($_POST["action"]=="do")
{
//处理数据
//先读取表头记录
$excel_file=$_POST["excel_file"];
$fh = @fopen ($excel_file,'rb');
$fc = fread( $fh, filesize($excel_file) );
@fclose($fh);
//echo("执行".$excel_file);
$exc = new ExcelFileParser("debug.log", ABC_NO_LOG);//ABC_NO_LOG ABC_VAR_DUMP);
//echo($excel_file."|");
$style = $_POST['style'];
if( $style == 'old' )
{
$fh = @fopen ($excel_file,'rb');
if( !$fh ) fatal("No file uploaded");
if( filesize($excel_file)==0 ) fatal("No file uploaded");
$fc = fread( $fh, filesize($excel_file) );
@fclose($fh);
if( strlen($fc) < filesize($excel_file) )
fatal("Cannot read file");
$time_start = getmicrotime();
$res = $exc->ParseFromString($fc);







