提交 ed3f9c7a 编写于 作者: D devil_gong

excel优化

上级 edbbd9a7
......@@ -108,52 +108,42 @@ return array(
// 用户excel导出标题列表
'excel_user_title_list' => array(
'username' => array(
'col' => 'A',
'name' => '姓名',
'name' => '用户名',
'type' => 'string',
),
'nickname' => array(
'col' => 'B',
'name' => '昵称',
'type' => 'int',
),
'gender_text' => array(
'col' => 'C',
'name' => '性别',
'type' => 'string',
),
'birthday_text'=> array(
'col' => 'D',
'name' => '生日',
'type' => 'string',
),
'mobile' => array(
'col' => 'E',
'name' => '手机号码',
'type' => 'int',
),
'email' => array(
'col' => 'F',
'name' => '电子邮箱',
'type' => 'string',
),
'province' => array(
'col' => 'G',
'name' => '所在省',
'type' => 'string',
),
'city' => array(
'col' => 'H',
'name' => '所在市',
'type' => 'string',
),
'address' => array(
'col' => 'I',
'name' => '详细地址',
'type' => 'string',
),
'add_time' => array(
'col' => 'J',
'name' => '注册时间',
'type' => 'string',
),
......
......@@ -113,9 +113,12 @@ class Excel
$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
$i = $k+2;
if(is_array($v) && !empty($v))
{
$temp_key = 0;
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.
先完成此消息的编辑!
想要评论请 注册