$value['job'] = $job['name']; } $j = 0; foreach ($h0 as $key1 => $fieldid) { $index = getColIndex($j) . intval($i + $k); $objPHPExcel->getActiveSheet()->setCellValue($index, $value[$key1]); $j++; $list[$i + $k][$index] = $value[$key1]; } $k++; } $i += $k - 1; } else { $j = 0; foreach ($h0 as $key1 => $fieldid) { $index = getColIndex($j) . $i; $objPHPExcel->getActiveSheet()->setCellValue($index, $value[$key1]); $j++; $list[$i][$index] = $value[$key1]; } } $i++; } $objPHPExcel->setActiveSheetIndex(0); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $filename = $_G['setting']['attachdir'] . './cache/' . random(5) . '.xlsx'; $objWriter->save($filename); $name = $title . ' - 人员信息表.xlsx'; $name = '"' . (strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($name) : $name) . '"'; $filesize = filesize($filename); $chunk = 10 * 1024 * 1024;
*/ if (!defined('IN_DZZ') || !defined('IN_ADMIN')) { exit('Access Denied'); } $h0 = array('username' => '姓名', 'email' => '邮箱', 'nickname' => '用户名', 'birth' => '出生日期', 'gender' => '性别', 'mobile' => '手机', 'weixinid' => '微信号', 'orgname' => '所属部门', 'job' => '部门职位'); $h1 = getProfileForImport(); $h0 = array_merge($h0, $h1); $title = '批量导入用户模板'; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator($_G['username'])->setTitle($title . ' - DzzOffice')->setSubject($title)->setDescription($title . ' Export By DzzOffice ' . date('Y-m-d H:i:s'))->setKeywords($title)->setCategory($title); $list = array(); // Create a first sheet $objPHPExcel->setActiveSheetIndex(0); $j = 0; foreach ($h0 as $key => $value) { $index = getColIndex($j) . '1'; $objPHPExcel->getActiveSheet()->setCellValue($index, $value); $list[1][$index] = $value; $j++; } $objPHPExcel->setActiveSheetIndex(0); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $filename = $_G['setting']['attachdir'] . './cache/' . random(5) . '.xlsx'; $objWriter->save($filename); $name = $title . '.xlsx'; $name = '"' . (strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'rv:11')) ? urlencode($name) : $name) . '"'; $filesize = filesize($filename); $chunk = 10 * 1024 * 1024; if (!($fp = @fopen($filename, 'rb'))) { exit('导出失败!'); }