찾다
php教程php手册php ExcelReader 读取Excel类

这是一款开源的php代码,ExcelReader是专业地excel表进行读写操作的,下面我们来看一款ExcelReader读取phprm.com.xls工作表实例吧,代码如下:

<?php
$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 &#39;www.phprm.com/reader.php&#39;;
$data = new spreadsheet_excel_reader();
$data->setoutputencoding(&#39;cpa25a&#39;);
$data->read($file_to_include);
error_reporting(e_all ^ e_notice);
echo " 
<style> 
.table_data 
{ 
 border-style:ridge; 
 border-width:1; 
} 
.tab_base 
{ 
 background:#c5d0dd; 
 font-weight:bold; 
 border-style:ridge; 
 border-width:1; 
 cursor:pointer; 
} 
.table_sub_heading 
{ 
 background:#cccccc; 
 font-weight:bold; 
 border-style:ridge; 
 border-width:1; 
} 
.table_body 
{ 
 background:#f0f0f0; 
 font-wieght:normal; 
 font-size:12; 
 font-family:sans-serif; 
 border-style:ridge; 
 border-width:1; 
 border-spacing: 0px; 
 border-collaps教程e: collapse; 
} 
.tab_loaded 
{ 
 background:#222222; 
 color:white; 
 font-weight:bold; 
 border-style:groove; 
 border-width:1; 
 cursor:pointer; 
} 
</style> 
";
function make_alpha_from_numbers($number) {
    $numeric = "abcdefghijklmnopqrstuvwxyz";
    if ($number < strlen($numeric)) {
        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=&#39;javascript&#39;> 
var sheet_html = array(); ";
for ($sheet = 0; $sheet < count($data->sheets); $sheet++) {
    $table_output[$sheet].= "<table class=&#39;table_body&#39;> 
 <tr> 
  <td> </td>";
    for ($i = 0; $i < $data->sheets[$sheet][&#39;numcols&#39;] && ($i <= $max_cols || $max_cols == 0); $i++) {
        $table_output[$sheet].= "<td class=&#39;table_sub_heading&#39; align=center>" . make_alpha_from_numbers($i) . "</td>";
    }
    for ($row = 1; $row <= $data->sheets[$sheet][&#39;numrows&#39;] && ($row <= $max_rows || $max_rows == 0); $row++) {
        $table_output[$sheet].= "<tr><td class=&#39;table_sub_heading&#39;>" . $row . "</td>";
        for ($col = 1; $col <= $data->sheets[$sheet][&#39;numcols&#39;] && ($col <= $max_cols || $max_cols == 0); $col++) {
            if ($data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;colspan&#39;] >= 1 && $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;rowspan&#39;] >= 1) {
                $this_cell_colspan = " colspan=" . $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;colspan&#39;];
                $this_cell_rowspan = " rowspan=" . $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;rowspan&#39;];
                for ($i = 1; $i < $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;colspan&#39;]; $i++) {
                    $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col + $i][&#39;dontprint&#39;] = 1;
                }
                for ($i = 1; $i < $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;rowspan&#39;]; $i++) {
                    for ($j = 0; $j < $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;colspan&#39;]; $j++) {
                        $data->sheets[$sheet][&#39;cellsinfo&#39;][$row + $i][$col + $j][&#39;dontprint&#39;] = 1;
                    }
                }
            } else if ($data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;colspan&#39;] >= 1) {
                $this_cell_colspan = " colspan=" . $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;colspan&#39;];
                $this_cell_rowspan = "";
                for ($i = 1; $i < $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;colspan&#39;]; $i++) {
                    $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col + $i][&#39;dontprint&#39;] = 1;
                }
            } else if ($data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;rowspan&#39;] >= 1) {
                $this_cell_colspan = "";
                $this_cell_rowspan = " rowspan=" . $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;rowspan&#39;];
                for ($i = 1; $i < $data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;rowspan&#39;]; $i++) {
                    $data->sheets[$sheet][&#39;cellsinfo&#39;][$row + $i][$col][&#39;dontprint&#39;] = 1;
                }
            } else {
                $this_cell_colspan = "";
                $this_cell_rowspan = "";
            }
            if (!($data->sheets[$sheet][&#39;cellsinfo&#39;][$row][$col][&#39;dontprint&#39;])) {
                $table_output[$sheet].= "<td class=&#39;table_data&#39; $this_cell_colspan $this_cell_rowspan> ";
                if ($force_nobr) {
                    $table_output[$sheet].= "<nobr>";
                }
                $table_output[$sheet].= nl2br(htmlentities($data->sheets[$sheet][&#39;cells&#39;][$row][$col]));
                if ($force_nobr) {
                    $table_output[$sheet].= "</nobr>";
                }
                $table_output[$sheet].= "</td>";
            }
        }
        $table_output[$sheet].= "</tr>";
    }
    $table_output[$sheet].= "</table>";
    $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].= "<pre class="brush:php;toolbar:false">$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
  <script>//开源代码phprm.com change_tabs(0); </script>"; //echo ""; /* echo "
"; 
print_r($data); 
echo "
";  */

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


성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

SublimeText3 영어 버전

SublimeText3 영어 버전

권장 사항: Win 버전, 코드 프롬프트 지원!

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

mPDF

mPDF

mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경