<%
Set
DBCon = CreateObject("ADODB.Connection")
dbCon.Open "file
name=D:\wwwroot\util\Excel\strDB.udl"
'pathXsl =
Server.MapPath("\")&"\excel\excel_2.xls"
pathXslFile =
"D:\wwwroot\util\Excel\excel.xls"
Set
objFs =
CreateObject("Scripting.FileSystemObject")
Set
objFile = objFs.CreateTextFile(pathXslFile, true)
SQL = "Select id, comp_nm, dept_nm "
&_
"
From compinfo"
Response.Write "SQL :" & SQL &
"<br>"
Response.Write "생성될 파일경로 :" &
pathXslFile
Set
Rs = CreateObject("ADODB.RecordSet")
Rs.open SQL,
DBCon
' 셀의 제목이 될 부분
' " " 부분을
탭으로 밀어주면 필드별로 입력
xlsLine = " "
xlsLine = xlsLine & "번호" & "
"
xlsLine = xlsLine & "업체명" &
" "
xlsLine = xlsLine & "부서" & "
"
objFile.WriteLine(xlsLine)
xlsLine = " "
xlsLine = xlsLine & rs(0)
& " "
xlsLine = xlsLine & rs(1)
& " "
xlsLine = xlsLine & rs(2)
& " "
objFile.WriteLine(xlsLine)
Rs.MoveNext
LOOP
%>