How to NOT detect types for read range activity?

Hello!
I have found an inconvenience with the read range activity. When the activity read a cell in a xlsx-file with numbers in it, it automatically categorizes what type it is. For example, if a cell contains 2.123,95 UiPath pass it as a string, and if another cell contains 01234 it passes it as a int32 but takes away the zero and write it as 1234, and also 1,234 becomes a decimal and then converted to 1.234.

So for my question, is there some way around the automated type recognition that is built in read range? If a cell contains 01234, read range still pass it ass 01234, and so on?

1 Like

Hi,

I’m not sure I can help provide a good answer for this but I know the Read Range works similar to Excel. 01234 in Excel is looked at automatically as 1234 and removes the zero by Default. If you want Excel to see it as a string then you need a ’ character infront like '01234 or use a formula =“01234”. You can also simply change the formatting of the cells to a zero-filled number with formatting “00000” but the value still does not include the zero or the number as a string.

So, in my opinion, I think as a workaround you need to put the ’ character infront to force it to a string or just change the formatting of the columns the way you would like to display the number.

1 Like

Hi Andreas,

I believe Read range activity takes values as is from the xlsx-file. For cell with value 01234 check how it is displayed in formula bar of excel sheet. Excel suppresses the leading zeros even for customized numeric cell formats and hence uipath takes away the zero as well. One workaround will be to convert your numeric cells in excel to text format. With this read range will consider 01234 as string and write it as 01234 itself.

Looking forward to other constructive ideas.

Regards,
Srinath

Hi guys! Thank you for the input, unfortunately the excel-file comes from a third party and starting to manipulate the files is not really an alternative. Is there any other options?

Regards, AndreasB.

Suggestions:

  1. Request that the Excel column is formatted as ‘Text’ rather than ‘General’ - this will enable the value to be stored as string and not lose the ‘0’ without having to pre-fix with an apostrophe (') - the latter risks the ’ being read as part of the value.

  2. If you can’t change the format (you mentioned that it’s outside your control), then if the value you’re expecting/want is ‘01234’ and you get ‘1234’, then get length of value and if 4, append a ‘0’ to the start.

You could try to use Workbook activities instead. Maybe those give you a better result?

Hello @AndreasB
while using read cell actiivty, under Property>Options check the PreserveFormat checkbox… then UiPath will read it as string regardless of what type of data the cell contains.
same can be done for read range activity as well.

1 Like