ZendFramework dataset excel export solution

Source: Internet
Author: User
ZendFramework dataset excel export younger brother wants to export the dataset excel format read from the database (mysql) & nbsp; the frame used is ZF younger brother is a beginner. thank you !, ClassdownloadController Zend Framework dataset excel export
The younger brother wants to export the excel format of the dataset read from the database (mysql)

The frame we use is ZF. this is a beginner. thank you for your guidance!

------ Solution --------------------
Class downloadController extends Controlloer {
Function init (){}

Function download (){
// Query the database code to obtain the result set
// Write the result to the file aa. cvs
// Header (""); download

}
}

/Download "> Export

This is generally the case. Of course there are other methods.

}
------ Solution --------------------
Http://apps.hi.baidu.com/share/detail/35261920
------ Solution --------------------
PHP code
Header ("Content-Type: application/vnd. ms-excel "); header (" Content-Disposition: attachment; filename=test.xls "); header (" Pragma: no-cache "); header (" Expires: 0 "); $ title = mb_convert_encoding ('Recommendation information', 'gb2312', 'utf-8'); echo'
  
  
   
   
'; Echo'
   
   '; Echo' 
    
      '; If ($ recomType = 'customer') {// name of the output field $ zh = mb_convert_encoding ('recommender account', 'gb2312', 'utf-8 '); $ xm = mb_convert_encoding ('recommender name ', 'gb2312', 'utf-8'); $ sj = mb_convert_encoding ('recommender mobile phone no.', 'gb2312 ', 'utf-8'); $ bxm = mb_convert_encoding ('name of the recommender ', 'gb2312', 'utf-8'); $ bsj = mb_convert_encoding ('phone number of the recommender ', 'gb2312', 'utf-8'); $ bz = mb_convert_encoding ('Note description', 'gb2312', 'utf-8 '); $ time = mb_convert_encoding ('Recommendation time', 'gb2312', 'utf-8'); echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
    '; // Output Content foreach ($ allRecoms as $ key => $ outResult) {echo' 
    
      '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
     '; Echo' 
    ';} Echo' 
   
'. $ Title .'
'. $ Zh .''. $ Xm .''. $ Sj .''. $ Bxm .''. $ Bsj .''. $ Bz .''. $ Time .'
'. $ OutResult ['khzh'].''. $ OutResult ['khxm'].''. $ OutResult ['sjhm'].''. $ OutResult ['username'].''. $ OutResult ['usernumber'].''. $ OutResult ['usernote'].''. $ OutResult ['recomtime'].'
';

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.