When PHPexcel imports excel data, string format the data in the rows and columns_PHP tutorial

WBOY
Release: 2016-07-13 17:50:23
Original
1122 people have browsed it

In the process of using phpExcel, it is inevitable to encounter various problems, especially when importing excel tables. We always cannot get the expected excel data from the editor, such as the following:
When PHPexcel imports excel data, string format the data in the rows and columns_PHP tutorial

Obviously, I actually just want the text in this object, it it it. . . Some people won’t be able to bear it
In fact, the solution to this problem is very simple. Here is the entire code snippet

[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, just add a (string) in front of $objPHPExcel->getActiveSheet ()->getCell ( "$k$j" )->getValue ();
It's that simple!


Author longxuu

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478282.htmlTechArticleIn the process of using phpExcel, you will inevitably encounter various problems, especially when importing excel tables. , we always cannot get the expected excel data from the editor, such as the following...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template