이런 에러가 뜨는거보니 확장자명이 xls이라서 그런걸까요..?
csv, xlsx바꿔야한다는 게시글도 본것 같은데..
아래코드에서 수정할 수 없을까요?
조언이나 관련링크 부탁드립니다..버전은 gnuboard5.6.5입니다.

Copy
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
// 공통 파일 포함 경로를 찾는 함수
function is_common($inc) {
$root_dir = ["adm", "bbs", "extend"];
$dir_count = 0;
foreach ($root_dir as $g5_dir) {
if (is_dir($inc . $g5_dir)) {
$dir_count += 1;
}
}
return $dir_count === count($root_dir);
}
// 공통 파일 경로 설정
if (is_common("./")) {
$common_include = "./common.php";
} else {
$parent_dir = "../";
while (!is_common($parent_dir)) {
$parent_dir .= "../";
}
$common_include = $parent_dir . "common.php";
}
include_once($common_include);
// 관리자 여부 확인
if (!$is_admin) {
alert("관리자가 아닙니다.", "/");
}
// 테이블명 설정
$table_name = "g5_write_counsel";
$g5['title'] = "엑셀 문서 다운로드";
$excel_title = $config['cf_title'];
// 날짜 처리
$start_date = isset($_POST['start_date']) ? date('Y-m-d', strtotime($_POST['start_date'])) : '';
$end_date = isset($_POST['end_date']) ? date('Y-m-d', strtotime($_POST['end_date'])) : '';
$file_name = $start_date && $end_date ? $excel_title."_{$start_date}_{$end_date}" : $excel_title."_all_data";
// 헤더 설정
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename={$file_name}.xls");
header("Content-Description: PHP Generated Data");
// SQL 쿼리 설정
if ($start_date && $end_date) {
$query = "SELECT * FROM $table_name
WHERE wr_datetime BETWEEN '$start_date 00:00:00' AND '$end_date 23:59:59'
ORDER BY wr_datetime";
} else {
$query = "SELECT * FROM $table_name
WHERE wr_comment = 0
ORDER BY wr_datetime";
}
// 디버깅용: 쿼리 출력
echo "<pre>Executing query: $query</pre>";
// 쿼리 실행
$result = @sql_query($query);
if (!$result) {
die("Query execution failed. Please check the query syntax and database connection.");
}
?>
<html>
<head>
<title><?= htmlspecialchars($g5['title']) ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<tr style="text-align:center; height:30px;">
<td style="font-weight:bold;">순번</td>
<td style="font-weight:bold;">wr_datetime</td>
<td style="font-weight:bold;">wr_ip</td>
<td style="font-weight:bold;">wr_name</td>
<td style="font-weight:bold;">wr_1</td>
<td style="font-weight:bold;">wr_2</td>
<td style="font-weight:bold;">wr_3</td>
<td style="font-weight:bold;">wr_4</td>
<td style="font-weight:bold;">wr_5</td>
<td style="font-weight:bold;">wr_6</td>
<td style="font-weight:bold;">wr_7</td>
<td style="font-weight:bold;">wr_8</td>
<td style="font-weight:bold;">wr_9</td>
<td style="font-weight:bold;">wr_10</td>
<td style="font-weight:bold;">wr_content</td>
</tr>
<?php
$i = 0;
while ($data = sql_fetch_array($result)) {
$i++;
echo "<tr style='height:30px'>
<td>{$i}</td>
<td>{$data['wr_datetime']}</td>
<td>{$data['wr_ip']}</td>
<td>{$data['wr_name']}</td>
<td>{$data['wr_1']}</td>
<td>{$data['wr_2']}</td>
<td>{$data['wr_3']}</td>
<td>{$data['wr_4']}</td>
<td>{$data['wr_5']}</td>
<td>{$data['wr_6']}</td>
<td>{$data['wr_7']}</td>
<td>{$data['wr_8']}</td>
<td>{$data['wr_9']}</td>
<td>{$data['wr_10']}</td>
<td>{$data['wr_content']}</td>
</tr>";
}
// 데이터가 없는 경우
if ($i === 0) {
echo "<tr><td colspan='14' style='text-align:center;'>선택한 기간동안 데이터가 없습니다.</td></tr>";
}
?>
</table>
</body>
</html>
|
답변 4개 / 댓글 2개
채택된 답변
+20 포인트
1년 전
답변에 대한 댓글 2개
바트컨트롤
1년 전
1년 전
html 코드를 그대로 액셀로 저장하면 나오는 경고입니다
그누보드에 기본으로 들어있는 PHPExcel을 사용하면 됩니다
lib > PHPExcel
1년 전
소스 기능단의 오류라기 보다는 윈도우 보안상 문제라 해당 오류 안뜨게 하기 위해서는 참고 주소 처럼 레지스트리를 변경하셔야 할듯 보여집니다.
1년 전
해당 브라우저 과잉진단입니다.
크롬에서 테스트해보세요.
답변을 작성하려면 로그인이 필요합니다.
다른 엑셀 라이브러리를 통해 내보내야하나 싶어서요^^;