PHP generates Excel Solver

Source: Internet
Author: User
Found on the Internet Phpexcel generated a simple file, but in the end he was saved by the Save method, as if the output to Php://output (my understanding), the background permissions have not been (as if I can not access this address, I have logged in the background) and then download the file is logged on the page Build to server side and then redirect the download is fine, but I'm not good at this. Delete this file to Phpexcel not ripe solution or say change a library ~ ~ ~
$objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel5 '); $objWriter->save (Str_replace ('. php '), '. XLS ', __file__)); $callEndTime = Microtime (true); $callTime = $callEndTime-$callStartTime;


Reply to discussion (solution)

The above code is mistaken for the specific generated file code as follows:

 GetProperties ()->setcreator ("Maarten Balliauw")->setlastmodifiedby ("Maarten Balliauw")->settitle (" Office "xlsx Test Document")->setsubject ("Office" xlsx Test Document ")->setdescription (" Test document for Office of XLSX, generated using PHP classes. ") ->setkeywords ("Office openxml PHP")->setcategory ("Test result file");//Add some data$objphpexcel->            Setactivesheetindex (0)->setcellvalue (' A1 ', ' Hello ')->setcellvalue (' B2 ', ' world! ') ->setcellvalue (' C1 ', ' Hello ')->setcellvalue (' D2 ', ' world! '); /miscellaneous glyphs, Utf-8$objphpexcel->setactivesheetindex (0)->setcellvalue (' A4 ', ' Miscellaneous gly PHS ')->setcellvalue (' A5 ', ' Éàèùâêîôûëïüÿäöüç ');//Rename Worksheet$objphpexcel->getactivesheet ()->set Title (' simple ');//Set Active sheet Index to the first sheet, so Excel opens this as the first Sheet$objphpexcel->setac Tivesheetindex (0);//Redirect output To A client ' s Web browser (Excel2007) header (' content-type:application/ Vnd.openxmlformats-officedocument.spreadsheetml.sheet '); header (' Content-disposition:attachment;filename= ') 01simple.xlsx "'); header (' cache-control:max-age=0 ');//If you ' re serving to IE 9 and then the following is Neededheader (' Cache-control:max-age=1 '),//If you ' re serving to IE over SSL and then the following is Neededheader (' Expires:mon, 26 Jul 1997 05:00:00 GMT '); Date in the Pastheader (' last-modified: '. Gmdate (' d, D M Y h:i:s '). ' GMT '); Always Modifiedheader (' Cache-control:cache, Must-revalidate '); Http/1.1header (' pragma:public '); Http/1.0$objwriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel2007 '); $objWriter->save (' php:// Output '); exit;

From 61 to 71 rows are all about preparing for the browser output

If you just want to save to a file just
$objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel2007 ');
$objWriter->save (' filename ');
Can

Let's change the CSV. What XLS are you using now?

Fgetcsv Read
Fputcsv Write

Simply export Excel files
Http://jingyan.baidu.com/article/915fc414f4c2e451384b205c.html

To export an Excel file with a picture:
Http://jingyan.baidu.com/article/4f7d5712aea37f1a201927d7.html

  • Related Article

    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.