Using Excel spredsheet to create invoices

Hi everyone, I am relatively new to Ui design.

I have billing information for several customers in an Excel spreadsheet that I want to convert to actual Excel invoices. I am using Excel Application Scope, Read Range and For Each Row and Assign activities.

I am not sure 1) what variables to create and 2) what to put in the ForEach and In columns in For Each activity. Also 3) not sure what to use in a To and the column after the = in Assign.

Can anybody help?



In for each currentrow.ByField(“ColumnName”).StringValue will give the given column value for each iteration…

Make sure you check headers in excel for eqch and also give full range or only indicate the sheet so that full range is considered

And to write to a different excel use separate use excel for that and use write cell to write data

You can indicate on excel cell directly it creates the formula and value to write is taken from the abov egiven formula already


Hi, still not sure what to put into the value part of Assign. Bgr. Hallgrímur


If you just say not sure without trying its difficult to explain…try to first go through which has specific module for excel


I see what you mean. I tried this input the Assign activity: InvoiceNumber=InvoiceNumber+1 and ran the program then I got this error message:

Source: For Each Row in Data Table

Message: Object reference not set to an instance of an object.

Exception Type: System.NullReferenceException

RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at UiPath.Core.Activities.ForEach`1.StartLoop(NativeActivityContext context)
at UiPath.Core.Activities.InterruptibleLoopBase.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


Assign is for increment

And the error you gor is object ref which comes when a variable used is null or not intialized…so assign a value to it before using the variable


Hi Anil, to explain a little further. I am trying to use Assign to create invoices from an Excel file where in Column A are the invoice numbers from 3331 to 3337. Can you explain then what value I assign to it? Bgr. Hallgrímur


If you are already in for each excel row then as mentioned above you only need to get values which is by using assign…here invoivenumber is a string type variableinvoicenumber = currentrow.byfield("InvoiceColumnName").StringValue


Last try Anil, I promise.
Below is a copy of the Excel file A1-D8, where the InvoiceNumber is in A1 and 3331 is in A2. What should I type into the Value for the Invoice Number in the Assign activity? Brg. Hallgrímur

InvoiceNumber InvoiceDate CustomerName CompanyName
3331 07/11/2018 Fred Mendenhall
3332 07/11/2018 Susy Jensen
3333 12/11/2018 Stanley Call North Idaho Woodsman
3334 12/11/2018 Renee Armstrong Sanpete Pioneer Furniture
3335 13/11/2018 Scott Billings
3336 13/11/2018 Jason Young Exotic Pens from Platteville
3337 14/11/2018 Garren Linford Corvallis Creations

Hi, this is a screenshot of the project, with error messages:

Bgr. Hallgrímur


What you have in assign is correct…but as per error your datatable used invoicedata is empty…please check if you have used read range and if the datatable is assigned to output variable


Good morning, below is a screenshot of the Read Range:

Good morning. When I put InvoiceData into the DataTable output for the Read Range and ran the program, no Errors. Great. Thank you Anil

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.