Writing into group of cells in excel



Hello All,

I’m trying with a small automation project wherein i’m reading data from an image and writing it in an excel spreadsheet.
In the image there is a table with some data, I am trying to get the entire data from table into excel file.
For this i have created a string variable and loading the values of the scanned image in the variable.
(using the inbuilt OCR for scanning)
Then i’m writing the contents of this string variable in excel file.
While doing this i am getting the below error.

Caused by: org.openqa.selenium.WebDriverException: startup failed:
Script1.groovy: 5: expecting anything but ‘’\n’’; got it anyway @ line 5, column 28.

But when i write the data in notepad there is no issues.

Please let me know how to achieve this.


Post your code.


@sramu make sure you trim whitespaces from the OCR result variable and also check for hidden characters. They don’t show up in notepad but you can detect them in excel via the =LEN(cell) function.
Happened to me as well. OCR result was for example “123” but the LEN function showed there are 4 characters. So there was 1 hidden one. In my case it was in the beginning of the string so you substring the first character and get the right result.

        window(new com.workfusion.studio.rpa.recorder.api.groovy.WindowDescriptor("#32770", "Run", false, false).toString());
        window(new com.workfusion.studio.rpa.recorder.api.groovy.WindowDescriptor("Chrome_WidgetWin_1", "New Tab - Chromium", false, false).toString());

org.openqa.selenium.Rectangle i0 = $(byImage("1507114176414-anchor.apng")).getRect();
invoice1 = Ocr.proccessImage(sysOcrApiUrl.toString(), i0.x + 0, i0.y + 0, 750, 550);

setActiveCell("C:\\RPA\\Book1.xlsx", "A1")
setCell("C:\\RPA\\Book1.xlsx", "A1", "${invoice1}");



I’m trying to add multi-line text contents into excel.
And because of line break, the error is thrown.

When you paste the multi-line values into excel, the data will be spread in range of cells.
I’m hoping for a similar behavior with work fusion.
Is there any way to write multi-line string values in excel?



Not sure if that’s possible. As you state set cell for A1 I guess RPAx will only try to set that cell and the line break throws the error. Maybe via using a list variable where you first paste your OCR result can help.
Let’s see if any of the @workfusion guys can advise.



You can use the Text actions > Split String to get a List of values - see https://kb.workfusion.com/display/RPAe/Text#Text-SplitStringSplitString


@azinchuk, @timriewe
Thanks for the reply.
The solution will be to change the approach.
Instead of directly writing the multi-line text to excel, it has to be processed and value to be written separately in each cell.