103 lines
3.0 KiB
Plaintext
103 lines
3.0 KiB
Plaintext
<%@ LANGUAGE="VBSCRIPT" CodePage=65001 %>
|
|
<%
|
|
On Error Resume Next
|
|
Response.charset="UTF-8"
|
|
|
|
Set xlDb = Server.CreateObject("ADODB.Connection")
|
|
Set oRs = Server.CreateObject("ADODB.RecordSet")
|
|
|
|
excelName = URLDecode(Request("excelName"))
|
|
FileName = "D:\TEMP\" & excelName
|
|
|
|
|
|
connectString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & FileName & "; Extended Properties='Excel 12.0;HDR=NO;IMEX=1'"
|
|
xlDb.Open connectString
|
|
|
|
Dim resultTb(3, 16384)
|
|
fieldCount = 0
|
|
|
|
Dim excelRow
|
|
If LCase(Right(excelName, 4)) = "xlsx" Then
|
|
excelRow = "300000"
|
|
Else
|
|
excelRow = "65536"
|
|
End If
|
|
|
|
For i=0 To 63 ' 255 * 50 = 12,750번째 컬럼까지 확인 (빈칸나오면 멈춤)
|
|
stCol_n = 1 + (255 * i)
|
|
edCol_n = 255 + (255 * i)
|
|
Query = "SELECT * FROM [코딩 단가$" & excelColName(stCol_n) & "1:" & excelColName(edCol_n) & "3" & "] "
|
|
oRs.Open Query, xlDb, 1
|
|
If Err.number <> 0 Then '오류 발생 시 이 부분 실행
|
|
Exit For
|
|
End If
|
|
For row=1 To 3
|
|
For f=0 To oRs.Fields.Count-1
|
|
resultTb(row, f+fieldCount) = oRs.Fields(f).Value
|
|
Next
|
|
oRs.moveNext
|
|
Next
|
|
fieldCount = fieldCount + oRs.Fields.Count
|
|
oRs.Close
|
|
Next
|
|
|
|
Dim resultJson, qusNo, coderID, unitPay, firCount, totCount
|
|
resultJson = ""
|
|
qusNo = ""
|
|
coderID = ""
|
|
unitPay = ""
|
|
firCount = 0
|
|
totCount = 0
|
|
|
|
For i=0 To fieldCount
|
|
If Trim(resultTb(1, i)) = "코딩" Then
|
|
Query = "SELECT count(*) FROM [코딩 단가$" & excelColName(i+1) & "4:" & excelColName(i+1) & excelRow & "] "
|
|
Query = Query & "WHERE IIF(IsNull(F1), '', cstr(F1)) NOT IN ('', '998', '999', '9998', '9999')"
|
|
oRs.Open Query, xlDb, 1
|
|
If firCount = 0 Then
|
|
firCount = cLng(oRs.Fields(0).Value)
|
|
End If
|
|
totCount = totCount + cLng(oRs.Fields(0).Value)
|
|
oRs.Close
|
|
End If
|
|
If Trim(resultTb(2, i)) = "내근직코드" Then
|
|
If firCount <> 0 Then
|
|
resultJson = resultJson & "{""qusNo"":""" & qusNo & """,""firstCount"":""" & firCount & """,""totalCount"":""" & totCount & """,""coderID"":""" & coderID & """,""unitPay"":""" & unitPay & """},"
|
|
End If
|
|
qusNo = Trim(resultTb(1, i))
|
|
coderID = Trim(resultTb(2, i+1))
|
|
unitPay = Trim(resultTb(3, i+1))
|
|
firCount = 0
|
|
totCount = 0
|
|
End If
|
|
If i = fieldCount-1 Then
|
|
resultJson = resultJson & "{""qusNo"":""" & qusNo & """,""firstCount"":""" & firCount & """,""totalCount"":""" & totCount & """,""coderID"":""" & coderID & """,""unitPay"":""" & unitPay & """}"
|
|
End If
|
|
Next
|
|
xlDb.Close
|
|
|
|
Response.Write "[" & resultJson & "]"
|
|
|
|
function excelColName(num)
|
|
if num <= 26 then
|
|
excelColName = chr(num + 64)
|
|
else
|
|
div = int(num / 26)
|
|
modval = num mod 26
|
|
if modval = 0 then
|
|
modval = 26
|
|
div = div - 1
|
|
end if
|
|
excelColName = excelColName(div) + excelColName(modval)
|
|
End if
|
|
end function
|
|
|
|
function URLDecode(str)
|
|
Dim objScript
|
|
Set objScript = Server.CreateObject("ScriptControl")
|
|
objScript.Language = "JavaScript"
|
|
URLDecode = objScript.Eval("decodeURIComponent(""" & str & """.replace(/\+/g,"" ""))")
|
|
Set objScript = Nothing
|
|
end function
|
|
%>
|
|
|