Phpexcel string formatting of data in rows and columns when importing Excel data _php Tutorial

Source: Internet
Author: User
In the process of using phpexcel, you will inevitably encounter a variety of problems, especially in the import Excel table, we always can not get the desired Excel data from the editor, such as the following:


Obviously, I actually just want the text in this object, it's it ... Some of them can't stand it.
In fact, the solution to this method is very simple, the following is the entire code fragment

[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, $objphpexcel->getactivesheet ()->getcell ("$k $j")->getvalue (), plus one (string) in front of it.
It's so simple!


Author Longxuu

http://www.bkjia.com/PHPjc/478282.html www.bkjia.com true http://www.bkjia.com/PHPjc/478282.html techarticle In the process of using phpexcel, you will inevitably encounter a variety of problems, especially in the import Excel table, we always can not get the desired Excel data from the editor, such as the following ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.