PopUp with Excel file upload on Web

Hey there!

I was developing a web application and then I find a big problem.

I have an agent that import some information of Excel’s sheet and create documents for each line. On Client the agent runs perfectly, but at the web…

What I’ve tried to do: Create a pop up window that contains a field which gets the xls file and consume the information to generate the docs. The idea is so amazing but it doesn’t work in real…

My agent doesn’t work at web and I don’t know why. I turned on the debug and I got no errors. I’ve put some messagebox at the code to see the erros on sever console when the agent runs at web and I got nothing to. Even the F12 developers tools at IE I turned on and nothing happened. The only thing I have is AGENT DONE or THE PAGE CANNOT BE DISPLAYED.

Could you help to find where I got wrong?!

I’ll put the codes (javascript and lotusscript) below.

Thanks for advance and sorry for my english (I’m Brazialian!)

LOTUSSCRIPT:

Option Public

%REM

Agent MediaSemana

Created May 18, 2012 by Gabrielle Souza/4SR

Description: Comments for Agent

%END REM

Sub Initialize

On Error Goto erro

Dim s As New NotesSession 

Dim dbCur As NotesDatabase

Dim excel As Variant



MsgBox "Entrou no agente de importação"



Set dbCur = s.CurrentDatabase

Set excel = CreateObject("Excel.Application")

excel.workbooks.Open("C:\migracoes.xls")





Print |<script language=""Javascript"" type=""text/javascript"">|

Print|var path=window.location.pathname.substring(0,window.location.pathname.toLowerCase().indexof(".nsf")+4);|

Print |alert("Iniciando a Importação")|



MsgBox "iniciando a importaçao"



With Excel.ActiveSheet

	k=1

	Do Until .Cells(k, 1).Value = ""

		Set doc                = New NotesDocument(dbCur)

		doc.Form               = "Cadastro de migracao"

		doc.deployment         = .Cells(k, 1).Value

		doc.ad_time            = .Cells(k, 2).Value

		doc.firstname          = .Cells(k, 3).Value

		doc.LastName           = .Cells(k, 4).Value

		doc.domain             = .Cells(k, 5).Value

		doc.notes_server       = .Cells(k, 6).Value

		doc.notes_hierarchical = .Cells(k, 7).Value

		doc.nt_sam_account     = .Cells(k, 8).Value

		doc.site_location      = .Cells(k, 9).Value

		doc.machine_name       = .Cells(k, 10).Value

		doc.machine_type       = .Cells(k, 11).Value

		doc.drive_mappings     = .Cells(k, 12).Value

		doc.blend_name         = .Cells(k, 13).Value

		doc.blend_type         = .Cells(k, 14).Value

	

		Call doc.Save(True,False)

		k = k+1

	Loop

End With



Print |<script language=""Javascript"" type=""text/javascript"">|

Print|var path=window.location.pathname.substring(0,window.location.pathname.toLowerCase().indexof(".nsf")+4);|

Print |alert("Terminada a Importação")|



MsgBox "final da importacao"

Exit Sub

erro:

Msgbox "Erro: " & Error & " na linha " & Erl 

End

End Sub

JAVASCRIPT:

function importar() {

	alert("Para que sejam importadas as migrações é necessário que o arquivo Excel esteja na pasta 'C:\\' , com o nome de 'migracoes.xls'");

		var url = path + "/ImportaMigracoes?OpenAgent"  + "&1";

		form.Return.value = "["+ url + "]";

		form.submit();

		alert("Importação realizada com sucesso!");

					}

Subject: First things i would ask…

Is Excel actually installed on the server? If so, does the file you reference exist on the server’s C: drive?

Subject: yES

Yeah, I’ve already done it. and error still occurs.

Subject: Upload to server?

I can’t see the part where you upload the excel file on the server (if you had not code this, you will need to code an agent to take the file from web form and extract it to c:\migracoes.xls).

Do remember that a web agent would only run on the server and all the path will refer to the files on the server instead of the PC.