아미나 게시글 엑셀다운로드할때

아미나 게시글 엑셀다운로드할때

QA

아미나 게시글 엑셀다운로드할때

답변 2

본문

$wr_data = apms_unpack($row['wr_content']);

 

항목을 여러개 받아야해서 여분필드대신 이렇게 사용, 출력하는데요

엑셀에서만 출력이 안되네요ㅠㅠ

 

방법아시는분 계실까요?

이 질문에 댓글 쓰기 :

답변 2

엑셀쪽 에러 부터 확인 해야되요

include_once('../../../common.php');

$sql = " SELECT *  from {$write_table} where wr_is_comment = 0 order by wr_id asc";
    $result = sql_query($sql);
    $cnt = _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, "tmp-KaKao-Friends-Premium.xls");
    $workbook = new writeexcel_workbook($fname);
    $worksheet = $workbook->addworksheet();

    // Put Excel data
    $data = array('번호', '입금자명', '핸드폰번호', '카톡채널', '신청수량', '세금계산서' );
    $data = array_map('iconv_euckr', $data);

    $col = 0;
    foreach($data as $cell) {
        $worksheet->write(0, $col++, $cell);
    }

    $save_it_id = '';
    for($i=1; $row=sql_fetch_array($result); $i++)
    {
        $row = array_map('iconv_euckr', $row);

$wr_data = apms_unpack($row['wr_content']);

        $worksheet->write($i, 0, ' '.$i);
        $worksheet->write($i, 1, $row['wr_subject']);
        $worksheet->write($i, 2, $row['wr_content']);
        $worksheet->write($i, 3, $wr_data['kakao']);
        $worksheet->write($i, 4, $wr_data['amount']);
        $worksheet->write($i, 5, $wr_data['tax']);
    }
    $workbook->close();

    header("Content-Type: application/x-msexcel; name=\"KaKao-Friends-Premium-".date("ymd", time()).".xls\"");
    header("Content-Disposition: inline; filename=\"KaKao-Friends-Premium-".date("ymd", time()).".xls\"");
    $fh=fopen($fname, "rb");
    fpassthru($fh);
    unlink($fname);

    exit;

apms_unpack 은 줄바꿈으로 데이터를 구분합니다.

데이터 형식을 어떻게 넣으셨나요?

include_once('../../../common.php');

$sql = " SELECT *  from {$write_table} where wr_is_comment = 0 order by wr_id asc";
    $result = sql_query($sql);
    $cnt = _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, "tmp-KaKao-Friends-Premium.xls");
    $workbook = new writeexcel_workbook($fname);
    $worksheet = $workbook->addworksheet();

    // Put Excel data
    $data = array('번호', '입금자명', '핸드폰번호', '카톡채널', '신청수량', '세금계산서' );
    $data = array_map('iconv_euckr', $data);

    $col = 0;
    foreach($data as $cell) {
        $worksheet->write(0, $col++, $cell);
    }

    $save_it_id = '';
    for($i=1; $row=sql_fetch_array($result); $i++)
    {
        $row = array_map('iconv_euckr', $row);

$wr_data = apms_unpack($row['wr_content']);

        $worksheet->write($i, 0, ' '.$i);
        $worksheet->write($i, 1, $row['wr_subject']);
        $worksheet->write($i, 2, $row['wr_content']);
        $worksheet->write($i, 3, $wr_data['kakao']);
        $worksheet->write($i, 4, $wr_data['amount']);
        $worksheet->write($i, 5, $wr_data['tax']);
    }
    $workbook->close();

    header("Content-Type: application/x-msexcel; name=\"KaKao-Friends-Premium-".date("ymd", time()).".xls\"");
    header("Content-Disposition: inline; filename=\"KaKao-Friends-Premium-".date("ymd", time()).".xls\"");
    $fh=fopen($fname, "rb");
    fpassthru($fh);
    unlink($fname);

    exit;

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 2,432
© SIRSOFT
현재 페이지 제일 처음으로