PHP Update modify content in Excel example _php tutorial

Source: Internet
Author: User


































< td=""> $dir = $DOCUMENT _root. ' /backoffice/admin/oemcheck/'; $templateName = ' 1.xlsx ';$outputFileName = ' template. xlsx ';$txt = ' Test '; Instantiating an Excel Read class$PHPReader = new phpexcel_reader_excel2007 ();if (! $PHPReader->canread ($dir. $templateName)) {$PHPReader = new Phpexcel_reader_excel5 ();if (! $PHPReader->canread ($dir. $templateName)) {echo ' Unrecognized Excel file! ';return false;}}Read Excel$PHPExcel = $PHPReader->load ($dir. $templateName);Reading sheet 1$currentSheet = $PHPExcel->getsheet (0); $currentSheet->setcellvalue (' B13 ', iconv (' GBK ', ' utf-8 ', $txt));//table header assignment//Instantiate Excel Write Class Www.111cn.net$PHPWriter = new phpexcel_writer_excel2007 ($PHPExcel);Ob_start ();Header ("Content-type:application/force-download");Header ("Content-type:application/octet-stream");Header ("Content-type:application/download");Header (' Content-disposition:attachment;filename= '. $outputFileName. ' "');//Output template nameHeader ("Content-transfer-encoding:binary");Header ("last-modified:". Gmdate ("D, D M Y h:i:s"). " GMT ");Header (' Pragma:public ');Header (' expires:30 ');Header (' Cache-control:public ');$PHPWriter->save (' php://output ');
The code is as follows

From: http://www.111cn.net/phper/php/58174.htm articles you may be interested in
    • Phpexcel Generating Excel Code
    • PHP uses Phpexcel to generate Excel document instances
    • Phpexcel class exporting data from MySQL to XLS garbled
    • Phpexcel reading the Excel document code
    • Using Phpexcel to read Excel implementation code
    • Phpexcel read-Write XLS file implementation program
    • Phpexcel Error resolution when exporting Excel files
    • A detailed introduction to Phpexcel usage
    • Phpexcel Data Memory Overflow solution
    • The usage and introduction of Phpexcel

http://www.bkjia.com/PHPjc/738531.html www.bkjia.com true http://www.bkjia.com/PHPjc/738531.html techarticle The code is as follows $dir = $DOCUMENT _root. ' /backoffice/admin/oemcheck/'; $templateName = ' 1.xlsx '; $outputFileName = ' template. xlsx '; $txt = ' Test '; Instantiate Excel Read class $PHPReader = new ...

  • 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.