채택완료

게시글 엑셀다운로드시 꺠짐현상...

2019-11-30 (토) 02:54:34 5,178

예전 그누하마님의 스킨을적용하고자하는데....

엑셀로 게시물다운로드시에 한글이 깨집니다........

DB는 utf-8인데........다운로드하면 엑셀에서 한글이 전부 깨지네요......ㅠ.ㅠ

해결방법없을까요?

1036481997_1575050061.527.png

 

Copy
<?php

include_once('./_common.php');

 

$csv = 'xls';

 

// MS엑셀 XLS 데이터로 다운로드 받음

if ($csv == 'xls')

{

    

    if($_GET[stx]){ 

        $searches .= "and (wr_subject = '{$_GET[stx]}' or wr_content = '{$_GET[stx]}' or wr_1 = '{$_GET[stx]}' or wr_2 = '{$_GET[stx]}' or wr_3 = '{$_GET[stx]}'  or wr_3 = '{$_GET[stx]}'  or wr_3 = '{$_GET[stx]}')";

    }

    

    if($_GET[fr_date] && $_GET[to_date]){

 

        $fr_date_a = $_GET[fr_date]." 00:00:00";

        $to_date_a = $_GET[to_date]." 23:59:59";

 

        $searches .= "and (wr_datetime between '{$fr_date_a}' and '{$to_date_a}') ";

    }

 

    $sql = " SELECT * FROM g5_write_{$bo_table} where wr_is_comment = '0' {$searches}";

    $result = sql_query($sql);

    $cnt = sql_num_rows($result);

    if (!$cnt)

        alert("출력할 내역이 없습니다.");

 

    /*================================================================================

    php_writeexcel http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

    =================================================================================*/

 

    include_once(G5_LIB_PATH.'/Excel/php_writeexcel/class.writeexcel_workbook.inc.php');

    include_once(G5_LIB_PATH.'/Excel/php_writeexcel/class.writeexcel_worksheet.inc.php');

 

    $fname = tempnam(G5_DATA_PATH, $board.".xls");

    $workbook = new writeexcel_workbook($fname);

    $worksheet = $workbook->addworksheet();

 

    // Put Excel data

    $data = array('No','id(수정금지)','날짜','제목','필드1','필드2','필드3','필드4','필드5');

    $data = array_map('iconv_euckr', $data);

 

    $col = 0;

    foreach($data as $cell) {

        $worksheet->write(0, $col++, $cell);

    }


 

    for($i=1; $row=sql_fetch_array($result); $i++)

    {

        $row = array_map('iconv_euckr', $row);

        

        $up_date = date("y/m/d", strtotime($row['wr_datetime']));

         $worksheet->write($i, 0, $i);

         $worksheet->write($i, 1, $row['wr_id']);

         $worksheet->write($i, 2, $up_date);

         $worksheet->write($i, 3, $row['wr_subject']);

         $worksheet->write($i, 4, $row['wr_1']);

         $worksheet->write($i, 5, $row['wr_2']);

         $worksheet->write($i, 6, $row['wr_3']);

         $worksheet->write($i, 7, $row['wr_4']);

         $worksheet->write($i, 8, $row['wr_5']);

         /*

         $worksheet->write($i, 9, $row['wr_6']);

         $worksheet->write($i, 10, $row['wr_7']);

         $worksheet->write($i, 11, $row['wr_8']);

         $worksheet->write($i, 12, $row['wr_9']);

         $worksheet->write($i, 13, $row['wr_10']);

         */

    }

 

    $workbook->close();

    

    header("Content-charset=utf-8");

    header("Content-Type: application/x-msexcel; name=\"{$bo_table}-".date("ymd", time()).".xls\"");

    header("Content-Disposition: inline; filename=\"{$bo_table}-".date("ymd", time()).".xls\"");

    $fh=fopen($fname, "rb");

    fpassthru($fh);

    unlink($fname);

 

    exit;

}

 

if (mysql_num_rows($result) == 0)

{

    echo "<script>alert('출력할 내역이 없습니다.'); window.close();</script>";

    exit;

}

?>
|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트

 $row = array_map('iconv_euckr', $row);  왜 euckr로 변환하나요?

이 줄들 없애면 될 듯 한데요.

답변에 대한 댓글 1개

2019-12-02 (월) 21:12:53
아........감사합니다..
해결을해놓고 깜박했네요~
좋은저녁되세요~

답변을 작성하려면 로그인이 필요합니다.