In the process of using phpExcel, various problems are inevitable. Especially when importing an excel table, we cannot always obtain the expected excel Data from editing. For example, the following is:
Obviously, I only want the text in this object, and it just needs it... Some cannot stand it.
In fact, this solution is very simple. The following is the entire code snippet.
[Php]
<? Php
Require_once SITE_PATH. '/PHPExcle/Classes/PHPExcel. php ';
Require_once SITE_PATH. '/PHPExcle/Classes/PHPExcel/IOFactory. php ';
Require_once SITE_PATH. '/PHPExcle/Classes/PHPExcel/Reader/Excel5.php ';
$ ObjReader = PHPExcel_IOFactory: createReader ('excel5 ');
$ ObjPHPExcel = $ objReader-> load ($ fileurl );
$ Sheet = $ objPHPExcel-> getSheet (0 );
$ HighestRow = $ sheet-> getHighestRow ();
$ HighestColumn = $ sheet-> getHighestColumn ();
For ($ j = 2; $ j <= $ highestRow; $ j ++ ){
For ($ k = 'a'; $ k <= $ highestColumn; $ k ++ ){
$ Array [$ j] [$ k] = (string) $ objPHPExcel-> getActiveSheet ()-> getCell ("$ k $ j")-> getValue ();
}
}
?>
That is, add a (string) in front of $ objPHPExcel-> getActiveSheet ()-> getCell ("$ k $ j")-> getValue ();.
That's easy!
Author longxuu