Php updates and modifies the content in excel

Source: Internet
Author: User
In this example, you can read an existing Excel file instead of reading an Excel file or generating a new Excel file, and then modify the data in the Excel file, just like modifying the data in mysql .? Directory for storing php templates $ dir... in this example, instead of reading an Excel file or generating a new Excel file, you can read an existing Excel file and modify the data in the Excel file, just like modifying the data in mysql.

 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); // read the worksheet 1 $ currentSheet = $ PHPExcel-> getSheet (0); $ currentSheet-> setCellValue ('b13', iconv ('gbk ', 'utf-8', $ txt); // header assignment // instantiate the Excel writing class $ PHPWriter = new PHPExcel_Writer_Excel2007 ($ PHPExcel); ob_start (); header ("Content-Type: application/force-download"); header ("Content-Type: application/octet-stream"); header ("Content-Type: ap Plication/download "); header ('content-Disposition: attachment; filename = "'. $ outputFileName. '"'); // output Template name header (" 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');?>


Article URL:

Reprint ^ at will, but please attach the tutorial address.

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.