The code for reading excel files in PHPExcel is as follows:
$ Uploadfile = $ _ FILES ["file"] ['tmp _ name']; if (is_uploaded_file ($ uploadfile) & $ _ POST ['aid ']) {Vendor ('phpexcel. PHPExcel '); Vendor ('phpexcel. IOFactory '); Vendor ('phpexcel. reader. excel5 '); $ objReader = PHPExcel_IOFactory: createReader ('excel5'); // use excel2007 for 2007 format $ objPHPExcel = $ objReader-> load ($ uploadfile ); $ sheet = $ objPHPExcel-> getSheet (0); $ highestRow = 0; // get the total number of rows $ highestColumn = $ sheet-> getHighestColumn (); // obtain the total number of columns $ start = 1; // start from which line to input/delete if ($ _ POST ['didhang']) {// ignore the first row $ highestRow = $ sheet-> getHighestRow (); // Retrieve the total number of rows $ start = 2 ;} else {$ highestRow = ($ sheet-> getHighestRow (); // get the total number of rows} $ update = array (); $ delete = array (); // obtain the information field $ fresult = M ("form")-> where ("aid = % d", $ _ POST ['aid ']) -> order ("sort")-> select (); for ($ start; $ start <= $ highestRow; $ start ++) {// read the cell $ temp ['title'] = $ objPHPExcel-> getActiveSheet ()-> getCell ("B ". $ start)-> getValue (); // Property No. if the verification code is null, do not (empty ($ temp ['title']) {continue ;} $ temp ['assess'] = $ objPHPExcel-> getActiveSheet ()-> getCell ("C ". $ start)-> getValue (); $ temp ['is _ status'] = $ objPHPExcel-> getActiveSheet ()-> getCell ("D ". $ start)-> getValue (); $ temp ['sort '] = $ objPHPExcel-> getActiveSheet ()-> getCell ("E ". $ start)-> getValue (); $ temp ['aid '] =$ _ POST ['aid']; $ coll = ord ("F "); foreach ($ fresult as $ key => $ one) {$ temp ['form _ content'] [$ one ['id'] = $ objPHPExcel-> getActiveSheet () -> getCell (chr ($ coll ). $ start)-> getValue (); $ coll ++;} $ temp ['form _ content'] = serialize ($ temp ['form _ content']); if ($ objPHPExcel-> getActiveSheet ()-> getCell ("". $ start)-> getValue () {$ temp ['id'] = $ objPHPExcel-> getActiveSheet ()-> getCell ("". $ start)-> getValue (); array_push ($ delete, $ temp);} else {array_push ($ update, $ temp);} unset ($ temp );}
I don't understand why it is good or bad. when it is good, the array data can be normally output. when it is bad, the output data is as follows:
Array (2) {[0] => array (6) {["title"] => object (PHPExcel_RichText) #223 (1) {["_ richTextElements ": "PHPExcel_RichText": private] => array (2) {[0] => object (PHPExcel_RichText_Run) #224 (2) {["_ font": "PHPExcel_RichText_Run ": private] => object (PHPExcel_Style_Font) #227 (12) {["_ name": protected] => string (6) "too many characters" ["_ size ": protected] => int (11) ["_ bold": protected] => bool (false) ["_ italic": protected] => bool (false) ["_ superScript": protected] => bool (false) ["_ subScript": protected] => bool (false) ["_ underline ": protected] => string (4) "none" ["_ strikethrough": protected] => bool (false) ["_ color": protected] => object (PHPExcel_Style_Color) #228 (4) {["_ argb": protected] => string (8) "FF000000" ["_ parentPropertyName": protected] => NULL ["_ isSupervisor ": protected] => bool (false) ["_ parent": protected] => NULL} ["_ isSupervisor": protected] => bool (false) ["_ parent ": protected] => NULL ["colorIndex"] => int (8)} ["_ text": "PHPExcel_RichText_TextElement": private] => string (6) "Batch Bake"} [1] => object (PHPExcel_RichText_Run) #225 (2) {["_ font": "PHPExcel_RichText_Run": private] => object (PHPExcel_Style_Font) #230 (12) {["_ name": protected] => string (7) "Calibri" ["_ size": protected] => int (11) ["_ bold": protected] => bool (false) ["_ italic": protected] => bool (false) ["_ superScript ": protected] => bool (false) ["_ subScript": protected] => bool (false) ["_ underline": protected] => string (4) "none" ["_ strikethrough": protected] => bool (false) ["_ color": protected] => object (PHPExcel_Style_Color) #231 (4) {["_ argb": protected] => string (8) "FF000000" ["_ parentPropertyName": protected] => NULL ["_ isSupervisor ": protected] => bool (false) ["_ parent": protected] => NULL} ["_ isSupervisor": protected] => bool (false) ["_ parent ": protected] => NULL ["colorIndex"] => int (8)} ["_ text": "PHPExcel_RichText_TextElement": private] => string (5) "1-502" }}[ "assess"] => string (6) "" ["is_status"] => float (1) ["sort"] => float (1000) ["aid"] => string (3) "692" ["form_content"] => string (32) ": 2: {I: 829; d: 123; I: 830; d: 42225;} "} [1] => array (6) {["title"] => object (PHPExcel_RichText) #236 (1) {["_ richTextElements": "PHPExcel_RichText": private] => array (2) {[0] => object (PHPExcel_RichText_Run) #237 (2) {["_ font": "PHPExcel_RichText_Run": private] => object (PHPExcel_Style_Font) #240 (12) {["_ name": protected] => string (6) "too many characters" ["_ size": protected] => int (11) ["_ bold ": protected] => bool (false) ["_ italic": protected] => bool (false) ["_ superScript": protected] => bool (false) ["_ subScript": protected] => bool (false) ["_ underline": protected] => string (4) "none" ["_ strikethrough ": protected] => bool (false) ["_ color": protected] => object (PHPExcel_Style_Color) #241 (4) {["_ argb ": protected] => string (8) "FF000000" ["_ parentPropertyName": protected] => NULL ["_ isSupervisor": protected] => bool (false) ["_ parent": protected] => NULL} ["_ isSupervisor": protected] => bool (false) ["_ parent ": protected] => NULL ["colorIndex"] => int (8)} ["_ text": "PHPExcel_RichText_TextElement": private] => string (6) "Batch Bake"} [1] => object (PHPExcel_RichText_Run) #238 (2) {["_ font": "PHPExcel_RichText_Run": private] => object (PHPExcel_Style_Font) #243 (12) {["_ name": protected] => string (7) "Calibri" ["_ size": protected] => int (11) ["_ bold": protected] => bool (false) ["_ italic": protected] => bool (false) ["_ superScript ": protected] => bool (false) ["_ subScript": protected] => bool (false) ["_ underline": protected] => string (4) "none" ["_ strikethrough": protected] => bool (false) ["_ color": protected] => object (PHPExcel_Style_Color) #244 (4) {["_ argb": protected] => string (8) "FF000000" ["_ parentPropertyName": protected] => NULL ["_ isSupervisor ": protected] => bool (false) ["_ parent": protected] => NULL} ["_ isSupervisor": protected] => bool (false) ["_ parent ": protected] => NULL ["colorIndex"] => int (8)} ["_ text": "PHPExcel_RichText_TextElement": private] => string (5) "1-503" }}[ "assess"] => string (6) "mongobang" ["is_status"] => float (1) ["sort"] => float (1001) ["aid"] => string (3) "692" ["form_content"] => string (32) ": 2: {I: 829; d: 125; I: 830; d: 42225 ;}"}}
I want to know why the above data format is output and why it has a style
Reply to discussion (solution)
Don't you have any questions?
The problem is not completely described. what is the situation of good and bad times? Is the transfer of only the same file different? Is there a comparison format for different files? Xls or xlsx? Files in the same format are good or bad. do you want to open the file and compare the content?
The problem is not completely described. what is the situation of good and bad times? Is the transfer of only the same file different? Is there a comparison format for different files? Xls or xlsx? Files in the same format are good or bad. do you want to open the file and compare the content?
The file format is xls. when the time is good or bad, the file is the same. if you change the content, the file cannot be imported. the obtained data has some excel attributes. The file content must be different, but all are correct data. The file format is correct.
After the problem is solved, the type can be forcibly converted (string)
// Read the content of each cell cyclically. Note that the row starts from 1 and the column starts from.
For ($ rowIndex = 1; $ rowIndex <= $ allRow; $ rowIndex ++ ){
For ($ colIndex = 'a'; $ colIndex <= $ allColumn; $ colIndex ++ ){
$ Addr = $ colIndex. $ rowIndex;
$ Cell = $ currentSheet-> getCell ($ addr)-> getValue ();
If ($ cell instanceof PHPExcel_RichText) // rich text conversion string
$ Cell = $ cell->__ toString ();
Echo $ cell;
}
}