묻고답하기

엑셀파일로 변환한 후에도 콤마(,) 표시도 나타나고

콤마 뒷부분도 잘리지 않고 보이게 하려면 어떻게 해야 할지요?

str_replace 함수나 다른 방법이 혹시 있을까요?

 

게시판 내용의 엑셀파일 변환부분은 DB불러 오는 부분 제외하고 다음과 같은 형식이거든요..

$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>";    

 

$date = DateTime::createFromFormat("YmdHis",$val);

echo "<td>".htmlspecialchars($date->format('Y-m-d H:i:s'))."</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;

        }

 

    }

                $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");  

                    $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]=="contact"){  

                                echo str_replace("|@|","-",htmlspecialchars($extra_arr[1]));

}

                                elseif($extra_title[eid]=="date"){

$date = DateTime::createFromFormat("Ymd",$extra_arr[1]);

echo htmlspecialchars($date->format('Y-m-d'));

}

                            //기타 배열값들은 ',' 로 변경

                            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>";   

                }              

                /////////////////////////////////////////////////////////////////////

 

    echo"</tr>";

}

 

 

 

태그 연관 글
  1. [2016/12/30] 묻고답하기 회원 포인트를 엑셀로 받을 수 있나요? by 권만주 *2
  2. [2014/08/12] 묻고답하기 sql 에서 게시판 글 데이터를 엑셀화해서 한번에 올리려고합니다. by 모몽
  3. [2010/08/04] 묻고답하기 제로보드 게시판과 회원정보 변환방법 문의 드립니다. by 형명길
글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
궁금이 관리자페이지에서만 저장이 안되요.. file  
Shin958fe 홈페이지 복구 과정에서의 에러 발생 file  
메이크엠 글쓰기 필수 항목 안쓰면 알람 뜨는거 수정하려면..TT:  
마르팅 오류사항 체크 문의드립니다.  
ana**** XE 회원가입 허가 반영 [1] 2018.09.12 by sejin7940
가암자 sweet mobile 레이아웃에서 맨 위 메뉴의 글자크기 색을 바꾸고 싶습니다.  
물망초 seo 업데이트 했는데... 이런  
마르팅 게시판 글씨 께짐현상 문의드립니다. [3] file 2018.09.11 by 마르팅
마르팅 관리자 사이트메뉴편집에서 카테고리가 사라졌어요~~ [2] file 2018.09.11 by 마르팅
마꼬꼬 XE 레이아웃이나 모듈 등 구매에 관하여 [2] 2018.09.11 by DoorWeb
railman Sketchbook5 사이트 주소을 알고자 합니다. [1] 2018.09.11 by 너에게제공
쭈니쿠 어디 경로로 들어가야 확인할 수 있나요? [1] file 2018.09.10 by DoorWeb
kt**** 모바일화면에서 매일인증 창이 넘어가요 [1] file 2018.09.10 by DoorWeb
비타민 메인 슬라이드 세로 조절때문에 문의글 남겨봅니다.. [1] 2018.09.10 by DoorWeb
XE!! 게시판 엑셀 다운로드 오류 (한이73님 게시글 적용)  
쏘쏘쏘 회원 삭제가 안됩니다 [1] file 2018.09.10 by sejin7940
윤원 호스팅관련 추천좀 부탁 드립니다. [4] 2018.09.08 by 보트위
GELEE Xedition 스킨 사용 중 메인페이지 컨텐츠 정렬 관련 (초보자 질문 죄송합니다ㅠㅠ) [5] file 2018.09.07 by 르미
종합예술인 콘텐츠위젯 가운데 정렬 하는법 [4] file 2018.09.07 by 르미
mkp9**** 위젯 가운데 정렬 방법 [5] 2018.09.07 by 르미