묻고답하기

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

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

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 남기남
카이4525b 서버 이전... 총체적 난국입니다...ㅠㅠ [2] 2018.01.08 by 카이4525b
rail_man 섬네일 이미지가 일정하게 나타나지 않습니다. [4] 2018.01.08 by rail_man
타이레놀 메인화면에 최근게시물 안나오게 하는 방법이요 [1] 2018.01.08 by Ansi™
화랑529 사이트 이전했는데.. 왜 이런게 뜨나요 ??  
곰북이 로그인 오류  
waydo php 5.3에서만 작동합니다. [1] 2018.01.07 by waydo
유샤인 ver 1.9.2로 새로 만든 XE에 로그인 시에 이런 에러 메세지가 뜹니다.  
쮸야282 폰에서는 로그인인 되는데 웹에서는 안되네요. [1] file 2018.01.06 by 휘즈
11111a901f 팝업창 띄우는 방법 [1] 2018.01.06 by 휘즈
땁쓰 최신글 위젯에 최신글 노출이 않됩니다. [3] 2018.01.06 by DoorWeb
홈런볼11 자신이 작성한 게시물일 경우를 함수로 하면? [4] 2018.01.06 by 홈런볼11
바람처럼 한글테이블 명, 한글 필드명 사용 문제점  
이진수닷넷 게시판 분류관리, 먹통 [1] file 2018.01.05 by 파이팅건맨
ah Parse error  
rail_man 게시판 글꼴 크기를 좀더 세분화 할수는 없는지요????  
컴박살 카카오 로그인후 로그아웃을 어떻게 해야 할찌 ㅡ.ㅡ; [3] 2018.01.05 by 혁이
원샷 xe로 부트스트랩적용을 어떻게하나요..? [4] 2018.01.04 by 원샷
황금벌레 php 4.4.4 에서 확~ 업그레이드 하고 싶은데요. [1] 2018.01.04 by 황금벌레
서정민 네이버 로그인 연동 [11] 2018.01.04 by 아찌
아찌 네이버 로그인연동 질문 드립니다. file  
Jey Xedition does not work. Could you suggest a solution? [1] file 2018.01.04 by XE
잡순이 위젯페이지 모바일 CSS 어디서 수정해야되나요? [2] file 2018.01.04 by 잡순이
54o66352 포인트 초기화 이후 계속적으로 초기화됩니다.  
지나김 페이지(위젯) 무제한 생성 안되는 문제, 도움 주십시요. [1] 2018.01.03 by SimpleCode
달구벌 게시판제목 글자크기를 크게할수 없나요? [3] 2018.01.04 by 달구벌
카이4525b Php 5.2.11에 설치 가능 한 코어는 몇 버전 인가요? [2] 2018.01.03 by 카이4525b
o**** 레이아웃이 적용이 안되요 ㅠㅠ [1] file 2018.01.03 by 이근동
램램 XE에 문제가 생겼습니다. [1] 2018.01.03 by sejin7940
예진JEvans 게시물과 코멘트만 따로 백업하는 방법은 없나요? [1] 2018.01.03 by 디자인클립
Giant Search Result [1] 2018.10.19 by doorscope@yahoo.com