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

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

QA

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

본문

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

답변을 작성하시기 전에 로그인 해주세요.
전체 226
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT