PHP download Excel can not open the workaround

Source: Internet
Author: User
Tags php download

 php Solutions and considerations that cannot be opened after you download Excel, please refer to use

PHP download Excel file, 1, in the process of downloading do not output any non-file information, such as Echo log information. Otherwise, the downloaded file cannot be opened, prompting for formatting errors or corrupted files. 2, the output of Excel format must and suffix name to save all the time, no will also prompt format error or file corrupted   code as follows: if (File_exists (Cache_path. $file _name)) {      &N Bsp    //$this->logger->error (' File Realpath: '. Realpath (Cache_path. $file _name));       Header (' pragma:public ');       Header (' expires:0 ');       Header (' Content-encoding:none ');       Header (' Cache-control:must-revalidate, post-check=0, pre-check=0 ');       Header (' cache-control:public ');    header (' content-type:application/vnd.ms-excel ');         header (' Content-description:file Transfer ');       Header (' Content-disposition:attachment filename= '. $file _name);       Header (' content-transfer-encoding:binary ');       Header (' Content-length: FileSize (cache_path. $file _name));   &NBSP   ReadFile (cache_path. $file _name);  } else {    $this->logger->error (' Export model: '. $id. ' ERROR: No production file ');       echo ' < Script>alert (' Export error, File not exists! ') </script> ';  }    

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.