묻고답하기
게시글 엑셀 출력시 에러메세지가 왜 발생하는지 모르겠습니다. ㅠ
2018.11.13 09:06
엑셀 출력시 에러메세지가 발생이 되는데 어떻한 부분을 바꿔야 할까요?
<?php
//url 로 직접 불러오는것을 방지
if(!strstr($_SERVER['HTTP_REFERER'],$_SERVER['SERVER_NAME'])&& !strstr($_SERVER['HTTP_REFERER'],'out_excel.php')) exit;
$info = array(
"host" => "localhost",
"user" => "root",
"pass" => "autoset",
"db" => "dt",
"table" => "dt_documents",
"module_srl" => "737",
);
$getFields = array("title","regdate","content"); //출력원하는 칼럼을 배열로 입력
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=doc_".date('Ymd').".xls");
$con = mysql_connect($info[host], $info[user], $info[pass]) || die(mysql_error());
mysql_query("set names utf8");
$con_db = mysql_select_db($info[db]) || die(mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=Content-Type content=text/html; charset="utf-8">
</head>
<body>
<table border=1>
<tr align=center>
<?php
//제목 불러오기
$fields = mysql_list_fields("$info[db]", "$info[table]");
$columns = mysql_num_fields($fields);
for( $i=0 ; $i<$columns ; $i++ )
{
$field[$i]=mysql_field_name($fields, $i);
if( in_array($field[$i], $getFields) ) echo "<th>".$field[$i]."</th>";
}
//확장변수의 타이틀은 값이므로
$result = mysql_query("select var_name from xe_document_extra_keys where module_srl = $info[module_srl]");
while( $data = mysql_fetch_array($result) )
{
echo "<th>".htmlspecialchars($data[var_name])."</th>";
}
echo"</tr>";
//데이터 불러오기
$result = mysql_query("select * from $info[table] where module_srl = $info[module_srl]");
while( $data = mysql_fetch_assoc($result) )
{
echo"<tr>";
foreach( $data as $key => $val )
{
if( in_array($key, $getFields) )
{
if ($key == 'regdate') {
echo "<td style='mso-number-format:\"0_ \";' >".htmlspecialchars($val)."</td>";
}elseif ($key == 'content'){ //내용 출력할경우 태그가 그대로 출력됨
//echo "<td>".$val."</td>"; //셀이 두칸이상으로 늘어남
echo "<td >".htmlspecialchars(strip_tags(str_replace(" ","",$val)))."</td>";
}else {
echo "<td>".htmlspecialchars($val)."</td>";
}
}
if ($key == 'document_srl'){ //확장변수 불러올때 사용
$d_srl=$val;
}
}
//확장변수 출력 ////////////////////////////////////////////
//eid리스트를 불러온다
$query=mysql_query("select eid from xe_document_extra_keys where module_srl = $info[module_srl]");
while($extra_title=mysql_fetch_array($query))
{
echo"<td>";
$egetFields = array("value","eid");
//확장변수 값을 불러와 eid값이 같은곳에 출력
$extra_result = mysql_query("select * from xe_document_extra_vars where document_srl = $d_srl");
while( $edata = mysql_fetch_assoc($extra_result) )
{
$extra_str="";
foreach( $edata as $key => $val ){
if( in_array($key, $egetFields) ){
$extra_str = $val.",".$extra_str;
}
}
$extra_arr=explode(",",$extra_str);
if ($extra_title[eid]==$extra_arr[0]){
//전화번호값은 "|@|" 를 "-" 로 변경
if($extra_title[eid]=="mb_phone_Number"){
echo str_replace("|@|","-",htmlspecialchars($extra_arr[1]));
//기타 배열값들은 ',' 로 변경
}elseif($extra_title[eid]=="mb_incomplete"||$extra_title[eid]=="mb_cs"){
echo str_replace("|@|",",",htmlspecialchars($extra_arr[1]));
}else{
echo htmlspecialchars($extra_arr[1]);
}
}
}
echo"</td>"; //eid값이 없으면 빈칸입력
}
/////////////////////////////////////////////////////////////////////
echo"</tr>";
}
?>
</table>
</body>
</html>
댓글 0
글쓴이 | 제목 | 최종 글 |
---|---|---|
XE | 공지 글 쓰기,삭제 운영방식 변경 공지 [16] | 2019.03.05 by 남기남 |
문닫어추 |
게시글 엑셀 출력하는데 에러때문에 도움 부탁드립니다. ㅜ
![]() | |
쏠파파 | 마이그레이션 게시물 누락 [1] | 2018.11.14 by sejin7940 |
venus**** | 크래킹 당한 것인가요? [1] | 2018.11.14 by 도토리묵 |
호호홍 | xe 캐시 오류? 도움 구합니다 ㅜㅜ [1] | 2018.11.13 by sejin7940 |
문닫어추 |
게시판 사용자 정의 관련 문의 입니다.
[4]
![]() | 2018.11.13 by 문닫어추 |
프로초보 | 확장변수 단일선택 [2] | 2018.11.13 by 프로초보 |
Ru | 안녕하세요 xe 초보자 입니다. | |
LIFO | 회원가입 메일 인증 DB 구조 [2] | 2018.11.13 by LIFO |
문닫어추 |
게시글 엑셀 출력시 에러메세지가 왜 발생하는지 모르겠습니다. ㅠ
![]() | |
fasflpelqwe | XEDITION 게시판썸네일 [1] | 2018.11.12 by sejin7940 |
magerod | 모바일 레이아웃 미사용시 헤더스크립트가 불러지지 않습니다. | |
리리즈 | 설치된 레이아웃 관리자 화면에서 내용 수정시 \\ ←모양이 자동으로 붙는 현상 [2] | 2018.11.12 by 리리즈 |
문닫어추 |
사용자 정의 형식 변경 하는 방법 문의 드립니다.
[2]
![]() | 2018.11.12 by 문닫어추 |
프레드 | 갑자기 접속이 느려지는데 이게 무슨 문제인지 모르겠네요 | |
궁금이 | 관리자페이지에서만 저장이 안되는 문제 [1] | 2018.11.10 by 궁금이 |
jsk**** | common_layout.html 파일에 이상이 있는경우인거 같습니다. | |
krise |
ftp 설정에서 sftp에 대한 질문
![]() | |
하나보드 | 모바일 사용자들이 자꾸 로그인이 끊긴다 합니다. [1] | 2018.11.10 by 도토리묵 |
권주현 | 모듈 생성이 안됩니다.. [2] | 2018.11.10 by 도토리묵 |
Gambo |
홈페이지 위젯 이미지가 모두 No image 로 나옴니다.
[9]
![]() | 2018.11.10 by 아오테아 |