Failing to update excel using setRange

excel
code
set-range

#1

can someone help, I am trying to update excel using sample programs from help content.

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">

    <export include-original-data="true"></export>

	<script><![CDATA[    
	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 filepath = 'E:/inputFile.xlsx'
	
	values =['val1','val2','val3','val4']
	
	openExcel(filepath)
	
    setRange(filepath,'B2',values)
    
	]]></script>
</config>

I am getting below error: ----------------------------------------

21:17:40 [INFO] ExportPlugin starts processing…
21:17:40 [INFO] ExportPlugin processor executed in 15ms.
21:17:40 [INFO] ScriptProcessor starts processing…
21:17:41 [ERROR]
Config line 6: script block
java.lang.NullPointerException
org.webharvest.exception.ScriptException:
Config line 6: script block
java.lang.NullPointerException
at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:138)
at org.webharvest.runtime.processors.ScriptProcessor.execute(ScriptProcessor.java:74)
at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:173)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.processTaskInputs(SingleThreadWebHarvestProcess.java:77)
at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.start(SingleThreadWebHarvestProcess.java:46)
at com.workfusion.studio.launch.WebHarvestMainLauncher.launch(WebHarvestMainLauncher.java:108)
at com.workfusion.studio.launch.WebHarvestMainLauncher.main(WebHarvestMainLauncher.java:180)
Caused by: java.lang.NullPointerException
at com.workfusion.rpa.helpers.utils.ApiUtils.getDriverType(ApiUtils.java:133)
at com.workfusion.rpa.helpers.utils.ApiUtils.checkDesktopOrUniversalDriver(ApiUtils.java:108)
at com.workfusion.rpa.helpers.utils.ApiUtils.desktopDriver(ApiUtils.java:103)
at com.workfusion.rpa.helpers.Excel.openExcel(Excel.java:34)
at com.workfusion.rpa.helpers.Excel$openExcel.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:197)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:209)
at Script1.run(Script1.groovy:17)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:444)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:482)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:453)
at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:136)
… 9 more
21:17:41 [INFO] -------------------------------------------
21:17:41 [INFO] EXECUTION FAILED
21:17:41 [INFO] Exception occurred (updateExcel.xml:17)
21:17:41 [INFO] -------------------------------------------


#2

Hi @spanada

There is an error in the API docs. “Values” has to be a Table, not a List, so it should have double square brackets.

Also, you need to use robot plugin.

<?xml version="1.0" encoding="UTF-8"?>
<config
	xmlns="http://web-harvest.sourceforge.net/schema/1.0/config"
	scriptlang="groovy">


	<robotics-flow>
		<robot driver="universal" close-on-completion="true"
			start-in-private="false">
			<capability name="SEARCH_ALL_WINDOWS" value="true" />
			<capability name="CLOSE_ALL_WINDOWS" value="false" />
			<script><![CDATA[
				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 filepath = 'path//to/file'

				values = [['val1', 'val2', 'val3', 'val4']]

				openExcel(filepath)

				setRange(filepath,'B2',values)
			]]></script>
		</robot>
	</robotics-flow>
	<export include-original-data="false"></export>

</config>

#3

Hi @ashapkina,

got it.

Thank you.