반응형
-asp
  
  Len  :  길이반환       > len(str)
  LenB:  바이트 수 반환>Len(str)
  Left  :  왼쪽부터 지정위치까지 반환   > left(str,5)
  Right  :  오른쪽부터 지정위치까지 반환  > right(str,3)
  Mid  : 지정위치부터 지정위치까지 반환  > mid(str,4,5)
  instr  :  문자검색 시작위치 반환    > instr(str,"bob")
  Ltrim  :  왼쪽공백 제거      > ltrim(str)
  Rtrim  :  왼쪽공백 제거      > rtrim(str)
  Trim  : 양끝공백 제거     > trim(str)
  Split  : 지정문자 기준으로 배열에 넣기 > i=split(str,"/")  response.write i(0),i(1)
  Join  : 배열값들을 구분자와 함께 합침 > i=join(i,",") i(0),i(1)
  Replace : 문자열 변경      > replace(str,"in","out")
  Ucase  : 대문자로 변경     > ucase(str)
  Lcase  : 대문자로 변경     > lcase(str)
  FormatCurrency:통화값으로 반환    > FormatCurrency("100000")
  FormatNumber: 숫자로 서식화된 식 반환   > formatnumber("200000")
  FormatPercent:백분율값으로 반환    > FormatPercent(0.83838)
  string : 지정한수만큼 지정한 문자열 반환 > string(5,*)   *****
  StrReverse: 지정한문자 거꾸로 반환   > StrReverse(str)
  space  : 공백 출력      > space(10)
 
  FormatDateTime:날짜와 시간으로 서식화된 식 반환>formatdatetime(now,1) {0~4}
  Cdate  : date 형식으로 변경    > cdate("2010년 10월 08일")
  Date  : 현시스템 날짜 반환    > response.write date
  Dateadd : 지정한날짜에 계산 +,-   > dateadd("m",3,day) {yyyy,q,m,y,d,w,ww,h,n,s}
  Datediff : 두 날짜 간격     > datediff("h",firstTime,now) {yyyy,q,m,y,d,w,ww,h,n,s}
  Datepart : 날짜 지정 부분 반환    > datepart("y",date)
  DateSerial: 수식값들을 날짜로 반환   > dateserial(2000+10,12+5,4+12)
  DateValue : 시간정보를 제외한 날짜 변환반환 > datevalue(date)
  Month  : 지정 날짜에서 월 반환   > month(now)
  Day  : 지정 날짜에서 일 반환   > day(now)
  Hour  : 지정 날짜에서 시 반환   > Hour(now)
  Minute : 지정 날짜에서 분 반환   > Minute(now)
  Sencond : 지정 날짜에서 초 반환   > Sencond(now)
  IsDate : 날짜 형식인지 부울값 반환  > isdate(date)
  MonthName : 월이름을 약어또는 완전어로 반환 > monthname(month,true)
  Now  : 시스템의 날짜 시간 반환   
  Time  : 시간반환
  Timer  : 자정 이후 경과한 초 반환  
  TimeSerial: 수식값들을 시간으로 반환  > timeserial(5+3,10+3,3)
  Timevalue : 시간형으로 반환     > timevalue("오후 3:10:50")
  WeekDay : 요일을 나타내는 정수로 반환  > weekday(date,[firstdayofweek])
 일요일부터 토요일순 1~7 {yyyy,q,m,y,d,w,ww,h,n,s}
  WeekDayName: 요일명을 반환     > weekdayname(date,[firstdayofweek]) {yyyy,q,m,y,d,w,ww,h,n,s}
  Year  : 년도를 반환      > year(now)
  
  
 -mssql
 ascii('abcd')    :  아스키코드 반환 97
 char(97)      :  아스키코드를 문자열로 반환 'a'
 charindex('c','abcde',2) : 지정한 문자를 지정한 문자열에서 지정한 범위에서 검색하여 위치를 반환 3
 left('mssql',3)    : 왼쪽부터 3위치까지
 right('mssql',3)   :  오른쪽부터 3위치까지
 lower()      : 소문자로 변환
 upper()      : 대문자로 변환
 ltrim()      : 왼쪽공백 제거
 rtrim()      : 오른쪽쪽공백 제거
 nchar()      : 유니코드로 변환
 replace('mssql','ms','my') : 문자열 변환 
 replicate('sql',3)   : 중복출력 sqlsqlsql
 reverse('mssql')   : 역순반환 lqssm
 space(10)     : 공백(10개) 출력
 substring('mssql',2,5)  : 2위치에서 5위치까지 출력
 unicode('a')    : 유니코드값 출력
 isnumeric('30')    : 숫자 판별 참1, 거짓0
 isdate('20100910')   : 날짜 판별 참1, 거짓0
 len('감사')     : 문자열수 반환 2
 datalength('감사')   : 바이트수 반환 4
 
 DATEADD (Part,n,date)/Part부분에 n만큼 더한 date {yy,qq,mm,dy,dd,wk,hh,mi,ss,ms}
 YEAR,MONTH,DAY    :  해당파트 반환 {yy,qq,mm,dy,dd,wk,hh,mi,ss,ms}
 Datediff(dd,'1999/02/15','2000/02/15') : 차이반환 {yy,qq,mm,dy,dd,wk,hh,mi,ss,ms}
 datepart(part,date)   : 해당판트 반환 {yy,qq,mm,dy,dd,wk,hh,mi,ss,ms}
 cast(30e392 as char)  : 문자열로 치환
 convert(varchar, getdate(), 120): 문자열 서식 변환
 convert(datetime,'20101025',112): 날짜열 서식으로 변환
 
 is null   / is not null : .. where name is null
 nullif(123,'123a4')   : 두 문자를 비교하여 같으면 null 틀리면 첫 문자열을 반환 123
 
 GROUP FUCTION
 avg('컬럼1','컬럼2')  : 컬럼별 평균값 구하기,
  집게 함수를 사용하지 않는 컬럼이 함께 열람될 경우 group by 컬럼3 해준다.
 count(*)     : count(disinct column), count(all column), count(column), count(*)
  집게 함수를 사용하지 않는 컬럼이 함께 열람될 경우 group by 컬럼3 해준다.
 MAX / MIN      : 최고, 최소값
  집게 함수를 사용하지 않는 컬럼이 함께 열람될 경우 group by 컬럼3 해준다.
 SUM       : 함계
  집게 함수를 사용하지 않는 컬럼이 함께 열람될 경우 group by 컬럼3 해준다.
 
 CASE WHEN 'MSSQL'='MSSQL THEN 'Y' ELSE 'N'END

출처 - http://zietz.tistory.com/56
반응형

'공부거리 > ASP' 카테고리의 다른 글

ASP 엑셀 다운로드  (0) 2012.02.29
반응형

list.asp

<!--엑셀파일다운로드-->
 <form name="excel_form" action="excel.asp" method="post">
 <INPUT TYPE="hidden" name="sql" value="<%=sql%>">
  <%
  ' Writes a link to the newly created excel in the browser
  response.write "<a href='#' onclick='javascript:document.excel_form.submit();'><font color=red>특정 이력 사항</font></a> 엑셀 리스트 | 작성된 시간:  " & now() & "<br>"
  %>
 </form>
 </tr>
 <!--//엑셀파일다운로드-->

 


excel.asp

<!--#Include virtual=/include/DBconn.asp-->
<%
 Response.Buffer = TRUE
 Response.ContentType = "application/vnd.ms-excel"
 Response.CacheControl="public"
 Response.AddHeader "Content-Disposition", "attachment;filename=특정이력사항.xls"

 ''''''''''''''''''''' 리스트 가져오기''''''''''''''''''''''''''''''''''''''''''

sql=request("sql")
'response.write sql
'response.end
 'set result = dbConn.execute(sql)
 set Result = server.createobject("adodb.recordset")
 Result.open sql, DB, 1
 no=Result.RecordCount
 
 response.write "<font size=10>"& Result("buse_name") &"-"& Result("jiwon_type") &"</font>"

 if not result.eof then
  response.write "<table border=0 cellspacing=1 cellpadding=15 width=98% height=55 bgcolor='#454545'>" 
  response.write "<tr>"
  response.write "<td bgcolor='F3F3F3'>No.</td>"
  response.write "<td bgcolor='F3F3F3'>이름</td>"
  response.write "<td bgcolor='F3F3F3'>생년월일</td>"
  response.write "<td bgcolor='F3F3F3'>최종졸업학교</td>"
  response.write "<td bgcolor='F3F3F3'>전공</td>"
  response.write "<td bgcolor='F3F3F3'>졸업년도</td>"
  response.write "<td bgcolor='F3F3F3'>서류전형</td>"
  response.write "<td bgcolor='F3F3F3'>인적성검사</td>"
  response.write "<td bgcolor='F3F3F3'>1차면접</td>"
  response.write "<td bgcolor='F3F3F3'>2차면접</td>"
  response.write "<td bgcolor='F3F3F3'>3차면접</td>"
  response.write "<td bgcolor='F3F3F3'>경력</td>"
  response.write "</tr>"
  for i=1 to result.recordcount
   
   '서류 합격 여부
   If result("pass")<>"" Then
    pass=result("pass")
    If pass="ok" Then
    pass_result="합격"
    ElseIf pass="no" Then
    pass_result="불합격"
    End If
   End If
   
   '최종학교명
   If result("s_name1") <>"" Then
    school_name= result("s_name1")
    school_major=result("s_major1")
    gra_year=Left(result("s_year_E1") ,4)
   ElseIf result("s_name2") <>"" Then 
    school_name= result("s_name2")
    school_major=result("s_major2")
    gra_year=Left(result("s_year_E2") ,4)
   ElseIf result("s_name3") <>"" Then 
    school_name= result("s_name3")
    school_major=result("s_major3")
    gra_year=Left(result("s_year_E3") ,4)
   End If

   '전형별 점수
   SQL="select * from result where mem_id=" & result("idx")
   Set rs=server.createobject("ADODB.RECORDSET")
   rs.open sql,db,1,1
   If Not rs.eof then
    If rs("t_point")<>"" then
    t_point=rs("t_point")
    Else
    t_point="미응시"
    End If
    If rs("f_point")<>"" then
    f_point=rs("f_point")
    Else
    f_point="미응시"
    End if
    If rs("s_point")<>"" then
    s_point=rs("s_point")
    Else
    s_point="미응시"
    End if
    If rs("th_point")<>"" then
    th_point=rs("th_point")
    Else
    th_point="미응시"
    End if
   End If
   
   '경력사항
   If result("com_name1")<>"" Then
   company=result("com_name1")
   com_S1=result("com_S1")
   com_E1=result("com_E1")
   work=company & "("&com_S1&"~"&com_E1&")"
   End If
   If result("com_name2")<>"" Then
   company2=result("com_name2")
   com_S2=result("com_S2")
   com_E2=result("com_E2")
   work=work & "," & company2 & "("&com_S2&"~"&com_E2&")"
   End If
   If result("com_name3")<>"" Then
   company3=result("com_name3")
   com_S3=result("com_S3")
   com_E3=result("com_E3")
   work=work & "," & company3 & "("&com_S3&"~"&com_E3&")"
   End If
   If result("com_name4")<>"" Then
   company3=result("com_name4")
   com_S4=result("com_S4")
   com_E4=result("com_E4")
   work=work & "," & company4 & "("&com_S4&"~"&com_E4&")"
   End If
   response.write "<tr>"
   response.write  "<td bgcolor='FFFFFF'>" & i & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & result("u_name_H") & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & left(left(result("juminno"),6),2) &" 년 "& Right(left(result("juminno"),4),2) &" 월</td>"
   response.write  "<td bgcolor='FFFFFF'>" & school_name & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & school_major & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & gra_year & " 년</td>"
   response.write  "<td bgcolor='FFFFFF'>" & pass_result & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & t_point & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & f_point & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & s_point & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & th_point & "</td>"
   response.write  "<td bgcolor='FFFFFF'>" & work & "</td>"
   result.movenext
   response.write "</tr>"
  next
  response.write "</table>"
 end if
%>

 

페이지 결과를 엑셀파일로 저장하고 싶을때...

페이지 상단에 아래와 같은 코드를 넣으면 됩니다.

 

즉 웹브라우져에게 ContentType 를 엑셀이라고 알려주면 저장하거나 바로 웹브라우져에서 엑셀을 보여주거나

사용자의 설정에 따라 다르게 보여줄겁니다.

 

 Response.Buffer = False
 Response.Expires=0
 
 FileName = "" 


 Response.AddHeader "Content-Disposition","attachment;filename=" & FileName
 Response.ContentType = "application/vnd.ms-excel"  '''= 엑셀로 출력
 Response.CacheControl = "public"

 

그외

 

엑셀 : application/vnd.ms-excel

워드 : application/vnd.ms-word

파워포인트 : application/vnd.ms-powerpoint

 

 

덧 : Response.Buffer = False 와 Response.CacheControl = "public" 의 역할은 데이터를 버퍼링 하지 않고

바로 다운로드 창이 떠서 저장하기를 누르면 그때 데이터를 받아오도록 하는 기능입니다.


출처 - http://blog.naver.com/amoong25?Redirect=Log&logNo=100025985663
반응형

'공부거리 > ASP' 카테고리의 다른 글

asp - mssql - 함수모음  (0) 2012.03.07

+ Recent posts