엑셀 업로드 오류 해석
본문
제가 쇼핑몰 > 상품일괄등록 처럼 엑셀 다운 후 업로드 기능을 하고있습니다
근데 오류 내용이
Fatal error: Uncaught Error: Class 'Spreadsheet_Excel_Reader' not found in /home/giftcard/html/manager/itemexcelupdate.php:23 Stack trace: #0 {main} thrown in /home/giftcard/html/manager/itemexcelupdate.php on line 23
이건데 'Spreadsheet_Excel_Reader'를 못찾고 있는것인가요??
해결좀 해주세요ㅠㅠㅠ
아래는 php코드입니다
<?php
include_once('./_common.php');
ini_set("display_errors", 1);
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
$bo_tabel = "business_registratio";
// 상품이 많을 경우 대비 설정변경
set_time_limit ( 0 );
ini_set('memory_limit', '50M');
// auth_check($auth[$sub_menu], "w");
// function only_number($n)
// {
// return preg_replace('/[^0-9]/', '', $n);
// }
if($_FILES['excelfile']['tmp_name']) {
$file = $_FILES['excelfile']['tmp_name'];
include_once('/Excel/reader.php');
$data = new Spreadsheet_Excel_Reader();
// Set output Encoding.
$data->setOutputEncoding('UTF-8');
// ini_set('display_errors', '1');
/***
* if you want you can change 'iconv' to mb_convert_encoding:
* $data->setUTFEncoder('mb');
*
**/
/***
* By default rows & cols indeces start with 1
* For change initial index use:
* $data->setRowColOffset(0);
*
**/
/***
* Some function for formatting output.
* $data->setDefaultFormat('%.2f');
* setDefaultFormat - set format for columns with unknown formatting
*
* $data->setColumnFormat(4, '%.3f');
* setColumnFormat - set format for column (apply only to number fields)
*
**/
$data->read($file);
/*
$data->sheets[0]['numRows'] - count rows
$data->sheets[0]['numCols'] - count columns
$data->sheets[0]['cells'][$i][$j] - data from $i-row $j-column
$data->sheets[0]['cellsInfo'][$i][$j] - extended info about cell
$data->sheets[0]['cellsInfo'][$i][$j]['type'] = "date" | "number" | "unknown"
if 'type' == "unknown" - use 'raw' value, because cell contain value with format '0.00';
$data->sheets[0]['cellsInfo'][$i][$j]['raw'] = value if cell without format
$data->sheets[0]['cellsInfo'][$i][$j]['colspan']
$data->sheets[0]['cellsInfo'][$i][$j]['rowspan']
*/
// ini_set('display_errors', '1');
// $dup_it_id = array();
// $fail_it_id = array();
// $dup_count = 0;
// $total_count = 0;
// $fail_count = 0;
$succ_count = 0;
for ($i = 3; $i <= $data->sheets[0]['numRows']; $i++) {
$total_count++;
$j = 1;
$wr_subject = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_9 = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_10 = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_content = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_link1 = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_1 = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_2 = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_3 = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_4 = addslashes($data->sheets[0]['cells'][$i][$j++]);
$wr_5 = addslashes($data->sheets[0]['cells'][$i][$j++]);
// $it_explan2 = strip_tags(trim($it_explan));
// it_id 중복체크
// $sql2 = " select count(*) as cnt from {$g5['g5_shop_item_table']} where it_id = '$it_id' ";
// $row2 = sql_fetch($sql2);
// if($row2['cnt']) {
// $fail_it_id[] = $it_id;
// $dup_it_id[] = $it_id;
// $dup_count++;
// $fail_count++;
// continue;
// }
// 기본분류체크
// $sql2 = " select count(*) as cnt from {$g5['g5_shop_category_table']} where ca_id = '$ca_id' ";
// $row2 = sql_fetch($sql2);
// if(!$row2['cnt']) {
// $fail_it_id[] = $it_id;
// $fail_count++;
// continue;
// }
$sql = " INSERT INTO `{gift_write_business_registratio}`
SET wr_subject = '{$wr_subject}',
wr_9 = '{$wr_9}',
wr_10 = '{$wr_10}',
wr_content = '{$wr_content}',
wr_link1 = '{$wr_link1}',
wr_1 = '{$wr_1}',
wr_2 = '{$wr_2}',
wr_3 = '{$wr_3}',
wr_4 = '{$wr_4}',
wr_5 = '{$wr_5}'
";
sql_query($sql, true);
$wr_id = sql_insert_id();
$succ_count++;
}
}
$g5['title'] = '업체등록 결과';
include_once(G5_PATH.'/head.sub.php');
?>
<div class="new_win">
<h1><?php echo $g5['title']; ?></h1>
<div class="local_desc01 local_desc">
<p>업체등록을 완료했습니다.</p>
</div>
<dl id="excelfile_result">
<!-- <dt>총상품수</dt> -->
<!-- <dd><?//php echo number_format($total_count); ?></dd> -->
<dt>완료건수</dt>
<dd><?php echo number_format($succ_count); ?></dd>
<!-- <dt>실패건수</dt> -->
<!-- <dd><?//php echo number_format($fail_count); ?></dd> -->
<?//php if($fail_count > 0) { ?>
<!-- <dt>실패상품코드</dt> -->
<!-- <dd><?//php echo implode(', ', $fail_it_id); ?></dd> -->
<?//php } ?>
<!-- <?//php if($dup_count > 0) { ?> -->
<!-- <dt>상품코드중복건수</dt> -->
<!-- <dd><?//php echo number_format($dup_count); ?></dd> -->
<!-- <dt>중복상품코드</dt> -->
<!-- <dd><?//php echo implode(', ', $dup_it_id); ?></dd> -->
<?//php } ?>
</dl>
<div class="btn_win01 btn_win">
<button type="button" onclick="window.close();">창닫기</button>
</div>
</div>
<?php
include_once(G5_PATH.'/tail.sub.php');
?>
답변 3
해당 폴더에
_common.php
가 있나요?
include_once('/Excel/reader.php'); 여기서 말씀하신 함수를 불러 올거 같은데 경로가 맞는지 체크해보셔야 할거 같습니다.
Spreadsheet_Excel_Reader 함수 클래스기 존재하지 않는걸로 나오는데요
reader.php 불러오는 경로의 문제가 있는듯 한데 해당 라이브러리 경로로 제대로 불러오고 있는지 디버깅해서 체크해 보셔야 할듯 합니다.