【www.gdgbn.com--excel】

 代码如下

$allow_url_override = 1; // set to 0 to not allow changed via post or get
if(!$allow_url_override || !isset($file_to_include))
{
 $file_to_include = "111cn.net.xls";
}
if(!$allow_url_override || !isset($max_rows))
{
 $max_rows = 0; //use 0 for no max
}
if(!$allow_url_override || !isset($max_cols))
{
 $max_cols = 5; //use 0 for no max
}
if(!$allow_url_override || !isset($debug))
{
 $debug = 0;  //1 for on 0 for off
}
if(!$allow_url_override || !isset($force_nobr))
{
 $force_nobr = 1;  //force the info in cells not to wrap unless stated explicitly (newline)
}

require_once "www.111cn.net/reader.php";
$data = new spreadsheet_excel_reader();
$data->setoutputencoding("cpa25a");
$data->read($file_to_include);
error_reporting(e_all ^ e_notice);
echo "

";
function make_alpha_from_numbers($number)
{
 $numeric = "abcdefghijklmnopqrstuvwxyz";
 if($number  {
  return $numeric[$number];
 }
 else
 {
  $dev_by = floor($number/strlen($numeric));
  return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*strlen($numeric)));
 }
}
echo "<script language="网页特效">
var sheet_html = array(); ";
for($sheet=0;$sheetsheets);$sheet++)
{
 $table_output[$sheet] .= "
 
   ";
 for($i=0;$i<$data->sheets[$sheet]["numcols"]&&($i<=$max_cols||$max_cols==0);$i++)
 {
  $table_output[$sheet] .= "" . make_alpha_from_numbers($i) . "";
 }
 for($row=1;$row<=$data->sheets[$sheet]["numrows"]&&($row<=$max_rows||$max_rows==0);$row++)
 {
  $table_output[$sheet] .= "" . $row . "";
  for($col=1;$col<=$data->sheets[$sheet]["numcols"]&&($col<=$max_cols||$max_cols==0);$col++)
  {
   if($data->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<$data->sheets[$sheet]["cellsinfo"][$row][$col]["colspan"];$i++)
    {
     $data->sheets[$sheet]["cellsinfo"][$row][$col+$i]["dontprint"]=1;
    }
    for($i=1;$i<$data->sheets[$sheet]["cellsinfo"][$row][$col]["rowspan"];$i++)
    {
     for($j=0;$j<$data->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<$data->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<$data->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] .= " ";
    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] .= "";
 }
 $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;i<" , count($data->sheets) , ";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";

}
</script>";
echo "

";
for($sheet=0;$sheetsheets);$sheet++)
{
 echo "   onmousedown="change_tabs($sheet);">", $data->boundsheets[$sheet]["name"] , "";
}

echo
"";
echo "
www.111cn.net
<script language="网页特效">
change_tabs(0);
</script>";
//echo "";
/*
echo "

";
print_r($data);
echo "
";
*/

// excelreader这个类你可以到官网去下载哦。

本文来源:http://www.gdgbn.com/bangongshuma/26031/