묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
확장변수 엑셀로 출력하기 관련 질문입니다..
2012.08.24 17:54
검색해서 나오는 팁을 이용하여
계정에 php파일을 만들어 업로드 시키고 실행하였는데
정상적으로 파일 다운로드는 됩니다만..
엑셀파일을 열면 아래와 같이 오류가 뜨네요.
방법좀 부탁드려요..
<? $connect_host = "localhost"; $connect_id = "@@"; $connect_pass = "@@"; $connect_db = "@@"; $connect_table = "xe_document_extra_vars"; $xls_filename = "@@.xls"; $connect=@mysql_connect($connect_host,$connect_id,$connect_pass); @mysql_query("set character set utf8"); // 한글 입출력 문제 해결을 위해.. $mysql=@mysql_select_db($connect_db,$connect); header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=$xls_filename"); ?> <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8> <meta http-equiv=Content-Type content=text/html; charset=EUC-KR> </head> <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0"> <table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse"> <tr align=center> <? $fields = mysql_list_fields("$connect_db", "$connect_table"); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field[$i]=mysql_field_name($fields, $i); } ?> <tr> <td>항목A</td> <td>항목B</td> <td>항목C</td> <td>항목D</td> <td>항목E</td> <td>항목F</td> <td>항목G</td> </tr> <? /*$result=mysql_query("select * from $connect_table");*/ $result=mysql_query("select * from $connect_table where module_srl=281 order by document_srl, var_idx"); $ctmp = 1; echo "<tr>"; while($data=mysql_fetch_assoc($result)){ for ($i = 4; $i < sizeof($field); $i=$i+5) { echo "<td><span style='FONT-FAMILY:tahoma; FONT-SIZE:8pt;'>".$data["$field[$i]"]."</td>"; if($ctmp%7 == 0) // 확장변수 수만큼 값을 넣으세요. { echo "</tr>"; if($i+5<sizeof($field)){ echo "<tr>"; } } $ctmp = $ctmp + 1; } } ?> </table> </body> </html>
db이름 입력오류였네요.. 창피해라.. ^^;;