Phpexcel Exporting data

Source: Internet
Author: User

Baidu Phpexcel

After entering

Select Branches to enter Select version copy classes file renamed to Phpexcel

Here's a simple export I wrote with thinkphp3.2.3

Public Function Phpexcel () {
$path =str_replace (' \ \ ', '/', __file__);//
$arr =explode ('/', $path);
$STR = $arr [0]. ' /'. $arr [1]. ' /'. $arr [2]. ' /'. $arr [3]. ' /';//Assemble file path
$a = $str. ' public/home/phpexcel/';//define the path where the Phpexcel file is located
$b = $str. '/public/home/xlsx/'; Export Data path
Require $a. ' phpexcel.php '; Import Phpexcel File
Instantiate the Phpexcel class
$objPHPexcel = new \phpexcel ();
Gets the action object for the currently active sheet
$objSheet = $objPHPexcel->getactivesheet ();
Set a name for the current activity sheet
$objSheet->settitle (' demo ');
Populate data for the current activity sheet
/*
$objSheet->setcellvalue (' A1 ', ' name ')->setcellvalue (' B1 ', ' fractions ');//Line
$objSheet->setcellvalue (' A2 ', ' John Doe ')->setcellvalue (' B2 ', ' 20 ');//Column
$objSheet->setcellvalue (' A3 ', ' Harry ')->setcellvalue (' B3 ', ' 80 ');//Column
Generate an Excel file in the specified format
$objWriter =\phpexcel_iofactory::createwriter ($objPHPexcel, ' Excel2007 ');
$objWriter->save ($b. ' demo_2.xlsx ');
*/
$array = Array (
Array (' name ', ' score '),
Array (' John Doe ', ' 40 '),
Array (' Harry ', ' 60 '),
Array (' Zhao Liu ', ' 80 ')
);
$objSheet->fromarray ($array);
$objWriter =\phpexcel_iofactory::createwriter ($objPHPexcel, ' Excel2007 ');
$objWriter->save ($b. ' demo_3.xlsx ');
}

Phpexcel Exporting data

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.