<%
detalle = request("detalle")
porfecha = cdate(request("fecha"))
principal = "princ"
contratista = "cont"
periodo = "perio"
'-------------------------- CONSULTA PARA GUARDAR DATOS -------------------------------------
sql2 = ""
sql2 = sql2 & " INSERT INTO rm_temp_liquidacion ( "
sql2 = sql2 & " id_princ, "
sql2 = sql2 & " id_cont, "
sql2 = sql2 & " id_rm, "
sql2 = sql2 & " id_trab, "
sql2 = sql2 & " id_haber, "
sql2 = sql2 & " id_descuento, "
sql2 = sql2 & " produccion_lt, "
sql2 = sql2 & " cuotas_lt, "
sql2 = sql2 & " valor_lt, "
sql2 = sql2 & " fecha_lt, "
sql2 = sql2 & " id_usuario) "
sql2 = sql2 & " VALUES ("
sql2 = sql2 & " " & principal & ", "
sql2 = sql2 & " " & contratista & ", "
sql2 = sql2 & " " & periodo & ", "
'-------------------------- CONSULTA PARA GUARDAR DATOS -------------------------------------
if 10 = 10 then
on error resume next
filename=server.mappath("documentos/excel_productos.xls")' aqui va la ruta del archivo que quieres cargar
Set fs = CreateObject("Scripting.FileSystemObject")
Set readfile=fs.OpenTextFile(filename,1,False)
if err <> 0 then
Response.Write("<hr>"&err.description&"<hr>")
Response.End()
end if
linea = 0
contar = 1
ver = 0
guardafila = ""
filas = 0
Do while not readfile.atendofstream
on error resume next
if err <> 0 then
Response.Write("ERROR : "&err.description)
exit do
else
' Text=readfile.skipline 'salta una linea
' Text=readfile.skip(74)' salta "n" numero de caracteres
Text = readfile.readline 'lee la linea en donde quedo el cursor
if CLng(InStr(Text, "name=encabezado>")) > 0 then'---->limpia codigo para iniciar
ver = 1
Response.Write("<table border=1>")
end if
if CLng(InStr(Text, "if supportMisalignedColumns]>")) > 0 then'---->limpia codigo para finalizar
ver = 0
Response.Write("</table>")
end if
if ver = 1 then
if CLng(instr(Text,"<tr")) <> 0 then'-------> encuentra el codigo del trabajador
inicio_ = CLng(instr(Text,"name="))+5
final_ = CLng(instr(Text,">"))
variable = MID(Text, inicio_, final_)
trabajador = replace(variable,">","")
'Response.Write("<hr>"&linea&".-"&filas&">"&trabajador)&"<br>"&vbCrLf
if filas > 0 then
sql2 = sql2 & " " & trabajador & ", "
if isnumeric(trabajador) then
Response.Write(sql2)&"<br>"
end if
end if
filas = filas + 1
else
'----- recuperacion nombre variable ---------------------------------------
if CLng(instr(Text,"</td>")) <> 0 then'-------> no hay fin en la fila
if guardafila = "" then'-------> si no hay filas inconclusas continuo sin problemas
inicio_ = CLng(instr(Text,"name="))+5
final_ = CLng(instr(Text,"</td>"))
variable = MID(Text, inicio_, final_)
variable = replace(variable,"</td>","")
'Response.Write(linea&"."&filas&".-"&variable)&"<br>"&vbCrLf
guardafila = ""
else'-------> hay filas inconclusas pero hay fin asi que busco mi dato
guardafila = guardafila&" "&Text
inicio_ = CLng(instr(guardafila,"name="))+5
final_ = CLng(instr(guardafila,"</td>"))-8
variable = MID(guardafila, inicio_, final_)
variable = replace(variable,"</td>","")
'Response.Write(linea&"."&filas&".-"&variable)&"<br>"&vbCrLf
guardafila = ""
end if
else'-------> como no hay fin en la fila guardo la fila para buscar en la fila siguiente su fin
guardafila = guardafila&" "&Text
' Response.Write(guardafila)&"<BR>"
end if
'----- recuperacion nombre variable ---------------------------------------
end if
end if
if ver = 1 then'---> visualiza codigo
' Response.Write Text& chr(13)
'Response.Write(linea)&".-"& Text& chr(13)
end if
linea = linea + 1
end if
loop
readfile.close
set readfile=nothing
set fs=nothing
end if
%>