提交 ed3f9c7a 编写于 作者: D devil_gong

excel优化

上级 edbbd9a7
...@@ -108,52 +108,42 @@ return array( ...@@ -108,52 +108,42 @@ return array(
// 用户excel导出标题列表 // 用户excel导出标题列表
'excel_user_title_list' => array( 'excel_user_title_list' => array(
'username' => array( 'username' => array(
'col' => 'A', 'name' => '用户名',
'name' => '姓名',
'type' => 'string', 'type' => 'string',
), ),
'nickname' => array( 'nickname' => array(
'col' => 'B',
'name' => '昵称', 'name' => '昵称',
'type' => 'int', 'type' => 'int',
), ),
'gender_text' => array( 'gender_text' => array(
'col' => 'C',
'name' => '性别', 'name' => '性别',
'type' => 'string', 'type' => 'string',
), ),
'birthday_text'=> array( 'birthday_text'=> array(
'col' => 'D',
'name' => '生日', 'name' => '生日',
'type' => 'string', 'type' => 'string',
), ),
'mobile' => array( 'mobile' => array(
'col' => 'E',
'name' => '手机号码', 'name' => '手机号码',
'type' => 'int', 'type' => 'int',
), ),
'email' => array( 'email' => array(
'col' => 'F',
'name' => '电子邮箱', 'name' => '电子邮箱',
'type' => 'string', 'type' => 'string',
), ),
'province' => array( 'province' => array(
'col' => 'G',
'name' => '所在省', 'name' => '所在省',
'type' => 'string', 'type' => 'string',
), ),
'city' => array( 'city' => array(
'col' => 'H',
'name' => '所在市', 'name' => '所在市',
'type' => 'string', 'type' => 'string',
), ),
'address' => array( 'address' => array(
'col' => 'I',
'name' => '详细地址', 'name' => '详细地址',
'type' => 'string', 'type' => 'string',
), ),
'add_time' => array( 'add_time' => array(
'col' => 'J',
'name' => '注册时间', 'name' => '注册时间',
'type' => 'string', 'type' => 'string',
), ),
......
...@@ -113,9 +113,12 @@ class Excel ...@@ -113,9 +113,12 @@ class Excel
$charset = lang('common_excel_charset_list')[$excel_charset]['value']; $charset = lang('common_excel_charset_list')[$excel_charset]['value'];
// 标题 // 标题
foreach($this->title as $v) $temp_key = 0;
foreach($this->title as $k=>$v)
{ {
$excel->getActiveSheet()->setCellValue($v['col'].'1', ($excel_charset == 0) ? $v['name'] : iconv('utf-8', $charset, $v['name'])); $col = \PHPExcel_Cell::stringFromColumnIndex($temp_key);
$excel->getActiveSheet()->setCellValue($col.'1', ($excel_charset == 0) ? $v['name'] : iconv('utf-8', $charset, $v['name']));
$temp_key++;
} }
// 内容 // 内容
...@@ -124,9 +127,12 @@ class Excel ...@@ -124,9 +127,12 @@ class Excel
$i = $k+2; $i = $k+2;
if(is_array($v) && !empty($v)) if(is_array($v) && !empty($v))
{ {
$temp_key = 0;
foreach($this->title as $tk=>$tv) foreach($this->title as $tk=>$tv)
{ {
$excel->getActiveSheet()->setCellValueExplicit($tv['col'].$i, ($excel_charset == 0) ? $v[$tk] : iconv('utf-8', $charset, $v[$tk]), \PHPExcel_Cell_DataType::TYPE_STRING); $col = \PHPExcel_Cell::stringFromColumnIndex($temp_key);
$excel->getActiveSheet()->setCellValueExplicit($col.$i, ($excel_charset == 0) ? $v[$tk] : iconv('utf-8', $charset, $v[$tk]), \PHPExcel_Cell_DataType::TYPE_STRING);
$temp_key++;
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册