/**
- 导出
- @param
- @param
- @return
*/
public function exportexcel()
{
set_time_limit(0);
ini_set(‘memory_limit’, ‘1024M’);
vendor(“PHPExcel.PHPExcel.PHPExcel”);
vendor(“PHPExcel.PHPExcel.Writer.IWriter”);
vendor(“PHPExcel.PHPExcel.Writer.Abstract”);
vendor(“PHPExcel.PHPExcel.Writer.Excel5”);
vendor(“PHPExcel.PHPExcel.Writer.Excel2007”);
vendor(“PHPExcel.PHPExcel.IOFactory”);
//$data = Db::table(‘enroll_activity_hotel’)->where(‘is_del’, ‘0’)->field(‘name,address,phone,departure_time,two_room,three_room’)->select();
$name = ‘酒店列表’;
$excel = new \PHPExcel(); //引用phpexcel
iconv(‘UTF-8’, ‘gb2312’, $name); //针对中文名转码
$header = [‘酒店名称’, ‘酒店地址’, ‘酒店电话’, ‘发车时间’, ‘两人间数’, ‘三人间数’]; //表头,名称可自定义
$excel->setActiveSheetIndex(0);
e x c e l − > g e t A c t i v e S h e e t ( ) − > s e t T i t l e ( excel->getActiveSheet()->setTitle( excel−>getActiveSheet()−>setTitle(name); //设置表名
$excel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(18);
$excel->getActiveSheet()->getColumnDimension(‘A’)->setWidth(30);
$excel->getActiveSheet()->getColumnDimension(‘B’)->setWidth(30);
$excel->getActiveSheet()->getColumnDimension(‘C’)->setWidth(30);
$excel->getActiveSheet()->getColumnDimension(‘D’)->setWidth(30);
$excel->getActiveSheet()->getColumnDimension(‘E’)->setWidth(30);
$excel->getActiveSheet()->getColumnDimension(‘F’)->setWidth(30);
l e t t e r = a r r a y ( ′ A ′ , ′ B ′ , ′ C ′ , ′ D ′ , ′ E ′ , ′ F ′ , ′ G ′ , ′ H ′ , ′ I ′ , ′ J ′ , ′ K ′ , ′ L ′ , ′ M ′ , ′ N ′ , ′ O ′ , ′ P ′ , ′ Q ′ , ′ R ′ , ′ S ′ , ′ T ′ , ′ U ′ , ′ V ′ , ′ W ′ , ′ X ′ , ′ Y ′ , ′ Z ′ , ′ A A ′ , ′ A B ′ , ′ A C ′ , ′ A D ′ , ′ A E ′ , ′ A F ′ , ′ A G ′ , ′ A H ′ , ′ A I ′ , ′ A J ′ , ′ A K ′ , ′ A L ′ , ′ A M ′ , ′ A N ′ , ′ A O ′ , ′ A P ′ , ′ A Q ′ , ′ A R ′ , ′ A S ′ , ′ A T ′ , ′ A U ′ , ′ A V ′ , ′ A W ′ , ′ A X ′ , ′ A Y ′ , ′ A Z ′ ) ; / / 生 成 表 头 f o r ( letter = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ'); //生成表头 for ( letter=array(′A′,′B′,′C′,′D′,′E′,′F′,′G′,′H′,′I′,′J′,′K′,′L′,′M′,′N′,′O′,′P′,′Q′,′R′,′S′,′T′,′U′,′V′,′W′,′X′,′Y′,′Z′,′AA′,