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'
'. $ Title .' |
'; 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'
'. $ Zh .' | '; Echo'
'. $ Xm .' | '; Echo'
'. $ Sj .' | '; Echo'
'. $ Bxm .' | '; Echo'
'. $ Bsj .' | '; Echo'
'. $ Bz .' | '; Echo'
'. $ Time .' | '; Echo'
'; // Output Content foreach ($ allRecoms as $ key => $ outResult) {echo'
'; Echo'
'. $ OutResult ['khzh'].' | '; Echo'
'. $ OutResult ['khxm'].' | '; Echo'
'. $ OutResult ['sjhm'].' | '; Echo'
'. $ OutResult ['username'].' | '; Echo'
'. $ OutResult ['usernumber'].' | '; Echo'
'. $ OutResult ['usernote'].' | '; Echo'
'. $ OutResult ['recomtime'].' | '; Echo'
';} Echo'
';