|
@@ -1194,19 +1194,19 @@ class Database
|
|
|
if ($data) {
|
|
|
$config = $this->config();
|
|
|
if (isset($config['manage']['excel']) && $config['manage']['excel']) {
|
|
|
- $method = 'excel_' . $config['manage']['excel'];
|
|
|
+ $method = 'excel';
|
|
|
$info = $this->info();
|
|
|
$data = $this->getAdminInfo($data);
|
|
|
- $this->$method($info, $data, $config);
|
|
|
+ $this->excel($info, $data, $config);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//print_r($data);die;
|
|
|
}
|
|
|
|
|
|
- private function excel_csv($info, $data, $config)
|
|
|
+ private function excel($info, $data, $config)
|
|
|
{
|
|
|
- $file = $info['list_header'] . '的' . $info['list_desc'] . '-' . $info['project_name'] . '.csv';
|
|
|
+ $file = $info['list_header'] . '的' . $info['list_desc'] . '-' . $info['project_name'];
|
|
|
|
|
|
$header = $body = array();
|
|
|
$i = 0;
|
|
@@ -1219,7 +1219,7 @@ class Database
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- $v['name'] = mb_convert_encoding($v['name'],'gb2312','utf-8');
|
|
|
+ //$v['name'] = mb_convert_encoding($v['name'],'gb2312','utf-8');
|
|
|
$header[$i] = $v['name'];
|
|
|
$i++;
|
|
|
$j = 0;
|
|
@@ -1253,7 +1253,7 @@ class Database
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $value = mb_convert_encoding($value,'gb2312','utf-8');
|
|
|
+ //$value = mb_convert_encoding($value,'gb2312','utf-8');
|
|
|
|
|
|
$body[$j][] = $value;
|
|
|
$j++;
|
|
@@ -1261,95 +1261,8 @@ class Database
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //print_r($header);
|
|
|
- //print_r($body);die;
|
|
|
|
|
|
- Dever::csv($body, $header, $file);
|
|
|
- }
|
|
|
-
|
|
|
- private function excel_phpexcel($info, $data, $config)
|
|
|
- {
|
|
|
- $xls = new \PHPExcel();
|
|
|
-
|
|
|
- $xls->getProperties()->setCreator("Dever Excel")
|
|
|
- ->setLastModifiedBy("Dever Excel")
|
|
|
- ->setTitle("Office 2007 XLSX Analysis Document")
|
|
|
- ->setSubject("Office 2007 XLSX Analysis Document")
|
|
|
- ->setDescription("Dever Excel")
|
|
|
- ->setKeywords("Dever Excel")
|
|
|
- ->setCategory("Dever Excel");
|
|
|
-
|
|
|
- $name = $info['list_header'] . '的' . $info['list_desc'] . '-' . $info['project_name'];
|
|
|
- # 全局导出
|
|
|
- $start = 65;
|
|
|
- $act = $xls->setActiveSheetIndex(0);
|
|
|
-
|
|
|
- $act->setTitle($name);
|
|
|
-
|
|
|
- $i = 0;
|
|
|
-
|
|
|
- foreach ($config['struct'] as $k => $v) {
|
|
|
- if (isset($v['list']) && $v['list']) {
|
|
|
- # 处理权限
|
|
|
- if (isset($v['auth'])) {
|
|
|
- $auth = $this->value($v['auth'], $data);
|
|
|
- if (!$auth) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- $num = 1;
|
|
|
- $cell = $this->_getChr($start, $i);
|
|
|
- $act->setCellValue($cell . '' . $num, $v['name']);
|
|
|
- $act->getColumnDimension($cell)->setWidth(20);
|
|
|
- $i++;
|
|
|
-
|
|
|
- foreach ($data as $ki => $vi) {
|
|
|
- if (isset($vi[$k])) {
|
|
|
- $num += 1;
|
|
|
-
|
|
|
- $value = $vi[$k];
|
|
|
-
|
|
|
- if (is_string($v['list'])) {
|
|
|
- $value = $this->value($v['list'], $data[$ki], $config['struct']);
|
|
|
- }
|
|
|
- if (isset($v['option'])) {
|
|
|
- $v['option'] = $this->option($v['option']);
|
|
|
- if (strstr($value, ',')) {
|
|
|
- $temp = explode(',', $value);
|
|
|
- $t = array();
|
|
|
- foreach ($temp as $vv) {
|
|
|
- if (isset($v['option'][$vv]) && is_array($v['option'][$vv])) {
|
|
|
- $t[] = $v['option'][$vv]['name'];
|
|
|
- } else {
|
|
|
- $t[] = $vv;
|
|
|
- }
|
|
|
- }
|
|
|
- $value = implode("\r\n", $t);
|
|
|
- } elseif (isset($v['option'][$value])) {
|
|
|
- if (is_array($v['option'][$value])) {
|
|
|
- $value = $v['option'][$value]['name'];
|
|
|
- } else {
|
|
|
- $value = $v['option'][$value];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $act->setCellValue($cell . $num, $value);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //$act->getStyle('A1:'.$k.'20')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); // 垂直居中
|
|
|
- //$act->getStyle('A1:'.$k.'20')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);// 水平居中
|
|
|
-
|
|
|
- $filename = $name . '.xlsx';
|
|
|
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
- header('Content-Disposition: attachment;filename="' . $filename . '"');
|
|
|
- header('Cache-Control: max-age=0');
|
|
|
-
|
|
|
- $write = \PHPExcel_IOFactory::createWriter($xls, 'Excel2007');
|
|
|
- $write->save('php://output');
|
|
|
+ Dever::excelExport($body, $header, $file);
|
|
|
}
|
|
|
|
|
|
private function _getChr($start, $num)
|
|
@@ -2515,18 +2428,6 @@ class Database
|
|
|
if ($data && isset($data['list'])) {
|
|
|
$xls = new \PHPExcel();
|
|
|
|
|
|
- /*
|
|
|
- if(class_exists('\\PHPExcel'))
|
|
|
- {
|
|
|
- $xls = new \PHPExcel();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dever::debug('Class \'PHPExcel\' not found');
|
|
|
- die;
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
$xls->getProperties()->setCreator("Maze Stat Excel")
|
|
|
->setLastModifiedBy("Maze Stat Excel")
|
|
|
->setTitle("Office 2007 XLSX Maze Document")
|