<br />
<b>Warning</b>:  Undefined array key "HTTP_ACCEPT_LANGUAGE" in <b>/www/wwwroot/01xj.net/wp-content/plugins/wp-ue/main.php</b> on line <b>13</b><br />
{"id":532,"date":"2014-10-07T10:08:46","date_gmt":"2014-10-07T02:08:46","guid":{"rendered":"http:\/\/www.01xj.net\/?p=532"},"modified":"2014-10-07T10:08:46","modified_gmt":"2014-10-07T02:08:46","slug":"phpexcel%e5%af%bc%e5%85%a5excel%e5%88%b0%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9a%84%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.01xj.net\/?p=532","title":{"rendered":"phpexcel\u5bfc\u5165excel\u5230\u6570\u636e\u5e93\u7684\u4ee3\u7801"},"content":{"rendered":"<p><span>phpexcel\u5b9e\u73b0\u5bfc\u5165\u5185\u5bb9\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/span><\/p>\n<pre class=\"lang-php prettyprint linenums pre-scrollable\">&lt;?php\r\n\/**\r\n* phpexcel\u5b9e\u4f8b \u5bfc\u5165\u6570\u636e\u5e93\r\n*\/\r\nerror_reporting(E_ALL); \/\/\u5f00\u542f\u9519\u8bef \r\nset_time_limit(0); \/\/\u811a\u672c\u4e0d\u8d85\u65f6 \r\n\r\ndate_default_timezone_set('Europe\/London'); \/\/\u8bbe\u7f6e\u65f6\u95f4 \r\n\r\n\/** Include path **\/\r\nset_include_path(get_include_path() . PATH_SEPARATOR . 'http:\/\/www.jbxue.com\/..\/Classes\/');\/\/\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf \r\n\r\n\/** PHPExcel_IOFactory *\/\r\ninclude 'PHPExcel\/IOFactory.php'; \r\n\r\n\/\/$inputFileType = 'Excel5';    \/\/\u8fd9\u4e2a\u662f\u8bfb xls\u7684 \r\n    $inputFileType = 'Excel2007';\/\/\u8fd9\u4e2a\u662f\u8ba1xlsx\u7684 \r\n\/\/$inputFileName = '.\/sampleData\/example2.xls'; \r\n$inputFileName = '.\/sampleData\/book.xlsx'; \r\n\r\n        echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'&lt;br \/&gt;'; \r\n        $objReader = PHPExcel_IOFactory::createReader($inputFileType); \r\n        $objPHPExcel = $objReader-&gt;load($inputFileName); \r\n        \/* \r\n        $sheet = $objPHPExcel-&gt;getSheet(0); \r\n        $highestRow = $sheet-&gt;getHighestRow(); \/\/\u53d6\u5f97\u603b\u884c\u6570 \r\n        $highestColumn = $sheet-&gt;getHighestColumn(); \/\/\u53d6\u5f97\u603b\u5217 \r\n        *\/    \r\n        $objWorksheet = $objPHPExcel-&gt;getActiveSheet();\/\/\u53d6\u5f97\u603b\u884c\u6570 \r\n        $highestRow = $objWorksheet-&gt;getHighestRow();\/\/\u53d6\u5f97\u603b\u5217\u6570 \r\n\r\n        echo 'highestRow='.$highestRow; \r\n        echo \"&lt;br&gt;\"; \r\n        $highestColumn = $objWorksheet-&gt;getHighestColumn(); \r\n        $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);\/\/\u603b\u5217\u6570 \r\n        echo 'highestColumnIndex='.$highestColumnIndex; \r\n        echo \"&lt;br \/&gt;\"; \r\n        $headtitle=array(); \r\n        for ($row = 1;$row &lt;= $highestRow;$row++) \r\n        { \r\n            $strs=array(); \r\n            \/\/\u6ce8\u610fhighestColumnIndex\u7684\u5217\u6570\u7d22\u5f15\u4ece0\u5f00\u59cb \r\n            for ($col = 0;$col &lt; $highestColumnIndex;$col++) \r\n            {  \r\n                $strs[$col] =$objWorksheet-&gt;getCellByColumnAndRow($col, $row)-&gt;getValue(); \r\n            }  \r\n              $info = array( \r\n                      'word1'=&gt;\"$strs[0]\", \r\n                    'word2'=&gt;\"$strs[1]\", \r\n                    'word3'=&gt;\"$strs[2]\", \r\n                    'word4'=&gt;\"$strs[3]\", \r\n              ); \r\n              \/\/\u5f15\u5904\u53ef\u653e\u7f6e\u4ee3\u7801\uff0c\u5199\u5165\u6570\u636e\u5e93 \r\n              print_r($info); \r\n              echo '&lt;br \/&gt;'; \r\n        } \r\n?&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>phpexcel\u5b9e\u73b0\u5bfc\u5165\u5185\u5bb9\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a &lt;?php&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-532","post","type-post","status-publish","format-standard","hentry","category-phpjsshell"],"_links":{"self":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=532"}],"version-history":[{"count":1,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/532\/revisions"}],"predecessor-version":[{"id":533,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/532\/revisions\/533"}],"wp:attachment":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}