Lesson 10 Workfusion Excel automation Set range, List and Table variables

Hi, my result was not the expected.
What’s wrong?

The excel file ‘listed temperature’ is supposed to be:

image

and the real result is like this:

image

I followed the youtube video https://www.youtube.com/watch?v=bdEz1vbSFt8

Hi @juliocesar can you share your recording?

Hi, I did exactly as in the video!

link video: https://www.youtube.com/watch?v=bdEz1vbSFt8

Script:

import com.workfusion.studio.rpa.recorder.api.*
import com.workfusion.studio.rpa.recorder.api.types.*
import com.workfusion.studio.rpa.recorder.api.custom.*
import com.workfusion.studio.rpa.recorder.api.internal.representation.*

import com.workfusion.bot.exception.*

        
            def city = RList.of()
            
        
            def temperature = RString.of('')
            
        
            def resulttable = RTable.builder().build()
            
        
            def resultlist = RList.of()
            
        
            def empty = RList.of()
            

com.workfusion.rpa.helpers.RPA.metaClass.static.$ = { Closure c -> c.call() } // Support for Expression action. Should be implemented in RPA class in next release.

enableTypeOnScreen()



openExcel("C:\\Users\\julio.cesar\\workfusion-workspace\\rpae_project\\Lesson10\\city names.xlsx")
    
    try {
            
        city = RList.of(getColumn("C:\\Users\\julio.cesar\\workfusion-workspace\\rpae_project\\Lesson10\\city names.xlsx", ExcelColumnRowPosition.FIRST))


    } finally {
closeExcel("C:\\Users\\julio.cesar\\workfusion-workspace\\rpae_project\\Lesson10\\city names.xlsx")
    }


    city.each( {name ->
        

            sleep(10000)
	timeouts().pageLoadTimeout(10000, java.util.concurrent.TimeUnit.MILLISECONDS)

    openChrome(UrlOperations.ensureProtocol("www.google.com"))

        


inDesktop {
        sendKeys(StringTransformations.escapeAutoitText("temperature of "))
}

        


inDesktop {
            
            sendKeys(StringTransformations.escapeAutoitText(name.toString()))
}

        


inDesktop {
        sendKeys(StringTransformations.getKeyPressText(28, 13, 10, 0))
}

        

            temperature = RString.of($(byXpath("//*[@id=\"wob_tm\"]")).text())

                    resultlist = resultlist + name;

                    resultlist = resultlist + temperature;

                        resulttable.addRow(resultlist);

    })



openExcel("C:\\Users\\julio.cesar\\workfusion-workspace\\rpae_project\\Lesson10\\listed temperatures.xlsx")
    
    try {
                /* 	 */

        setRange("C:\\Users\\julio.cesar\\workfusion-workspace\\rpae_project\\Lesson10\\listed temperatures.xlsx", "A1", resulttable.getRows().stream().map({ it.asList() }).collect(java.util.stream.Collectors.toList()))


saveExcel("C:\\Users\\julio.cesar\\workfusion-workspace\\rpae_project\\Lesson10\\listed temperatures.xlsx")
    } finally {
closeExcel("C:\\Users\\julio.cesar\\workfusion-workspace\\rpae_project\\Lesson10\\listed temperatures.xlsx")
    }

Can the share the details of the Constant Value action? Seems like it does nothing.
It should replace the list variable with an empty list.

How can I share all the recording? Do I need zip the folder and to send here?

Yes, you do.

But it looks like you don’t do anything in the Constant value action.
You need to click Enter List there and then OK to replace the variable with an empty list at the beginning of each loop.

1 Like

Are you talking about the Step 4?

Lesson10.rar (16.1 KB)

Yes, step 4.

Started on B, but It’s ok.

Thank you! I really appreciate it your help.

image

1 Like