Support Portal

for ProcessRobot and WinAutomation

Start a new topic

Copy Excel Data into a Web Application using a Loop

ADMIN

The following example extracts data from an excel spreadsheet, iterates through each row and inserts the data into a web application.


Import the process into your WinAutomation console and place the sample data 'Example_Sheet.xlsx' onto your desktop before you run the script.


The process automatically maps your desktop directory, launches Excel, and captures the data into a Data Table variable %ExcelData%.  Note that you can add or remove data from the sheet as required and the 'Read from Excel Worksheet' action will accurately capture all of the data.  When removing data from the Excel document to be processed, it is advised that you delete the entire row and not just the cell values.  If you simply delete the populated cells without refilling the data, this may result in phantom characters in your worksheet (the cell will be "empty", but not "null").


The process proceeds to iterate through each row of data in the Excel spreadsheet and pass the respective cell values into the web application using a 'For Each Loop' and interactive Web actions.  The controls for the web application were captured using the UI Spy (activated by pressing 'Select Control From Repository' > 'Add Control') within each interactive action.  The extracted Excel data values are also incorporated into the interactive web actions and are used to populate text fields and select drop down list values.


In this example, each row from %ExcelData% is extracted into variable %CurrentItem%.  Note that you can use the literal header names in the variable like

%CurrentItem["First_Name"]%, or you can use column index values if your data does not contain a header, or whether you just want to use column indexes.  In this case %CurrentItem["First_Name"]% and %CurrentItem[0]% would yield the same result when calling data in the loop action.


Additional information on the actions used throughout the process are included in the message tabs which are visible when opened in the Process Designer.  

waj
xlsx

1 person likes this idea

Hi, I probed this idea but I get next error when proccess try to open initial status of internet explorer...


Runtime Error: Failed to navigate


RunScript failed

 

WatiN.Core.Exceptions.RunScriptException: RunScript failed ---> System.UnauthorizedAccessException: Acceso denegado. (Excepción de HRESULT: 0x80070005 (E_ACCESSDENIED))
   en mshtml.IHTMLWindow2.execScript(String code, String language)
   en WatiN.Core.Native.InternetExplorer.IEUtils.[](String , IHTMLWindow2 , Boolean )
   --- Fin del seguimiento de la pila de la excepción interna ---
   en WatiN.Core.Native.InternetExplorer.IEUtils.[](String , IHTMLWindow2 , Boolean )
   en WatiN.Core.Native.InternetExplorer.IENativeDocument.RunScript(String scriptCode, Boolean forceRunOnTopWindow)
   en WatiN.Core.Native.InternetExplorer.IEUtils.InjectRuntimeLibrary(DomContainer domContainer)
   en WatiN.Core.Native.InternetExplorer.IEUtils.ReadElementAttribute(IBrowserFacade browser, String cssSelectorForElement, String attributeName)
   en WinAutomation.Shared.Runtime.WatiNLib.IEAutomationBrowser.(IBrowserFacade )
   en WinAutomation.Shared.Runtime.WatiNLib.IEAutomationBrowser.GoToWebPage(NavigationTypeToPerformEnum navigationTypeToPerform, String urlToNavigateTo, Boolean wait)
   en WinAutomation.Actions.Runtime.WebAutomationRuntime.(IBrowserFacade , Boolean , Int32 , TextVariant , Func`3 )
   en WinAutomation.Actions.Runtime.WebAutomationRuntime.(WebBrowserInstanceVariant , Boolean , TextVariant , WebPageCourseOfActionIfDialogAppearsEnum , Func`3 )
   en WinAutomation.Actions.Runtime.WebAutomationRuntime.GoToWebPage(WebBrowserInstanceVariant webBrowserInstanceVariant, NavigationTypeToPerformEnum navigationTypeToPerform, TextVariant urlToNavigateTo, Boolean waitForPageToLoad, TextVariant dialogButtonToPress, WebPageCourseOfActionIfDialogAppearsEnum courseOfActionIfDialogAppears)
   en WinAutomation.Actions.Runtime.WebAutomationActions.GoToWebPage(Variant webBrowserInstance, Variant urlToNavigateTo, Variant dialogButtonToPress, Int32 navigationTypeToPerform, Boolean waitForWebPageToLoad, Int32 courseOfActionIfDialogAppears)
System.UnauthorizedAccessException: Acceso denegado. (Excepción de HRESULT: 0x80070005 (E_ACCESSDENIED))
   en mshtml.IHTMLWindow2.execScript(String code, String language)
   en WatiN.Core.Native.InternetExplorer.IEUtils.[](String , IHTMLWindow2 , Boolean )

What can be happening? I attach my adapted process.


Thanks in advance,


Gonzalo

waj
Make sure you have done the below setup to use internet explorer for automation. https://support.softomotive.com/support/solutions/articles/35000050835-requirements-for-internet-explorer-and-custom-dialog
Login or Signup to post a comment