Zero in Excel

Good afternoon, UiPath experts! Please help. The question is: how to read from Excel, using UiPath, the values ​​of cells with leading zeros (0000000456) in the DataTable? In Excel, the cell type stands for “optional”. When I read it into the DataTable, I only have “456” …

If your cell like 「 '00005 」 or like =TEXT(5,“00000”), Read Cell Activity can read correctly.

image image
image
{
“message”: “000005”,
“level”: “Information”,
“logType”: “User”,
“timeStamp”: “16:42:44”,
“processVersion”: “1.0.0”,
“jobId”: “47654c1d-d18d-4ea8-9c9b-3e46c1cfb9bb”,
“robotName”: “TWFPG\N000171168”,
“machineId”: 0
}

{
“message”: “00005”,
“level”: “Information”,
“logType”: “User”,
“timeStamp”: “16:47:38”,
“processVersion”: “1.0.0”,
“jobId”: “68cab925-42a2-4061-b988-bf23ec35cb82”,
“robotName”: “TWFPG\N000171168”,
“machineId”: 0
}

Thank. Yes, cells are about this format, but when converted to a string, the zeros disappear …

It must be somehow converted into a string character by character

Hi @Russia_N_Novgorod , you can set variable as string


if you read cell as Int32 , I think 0 will disappear.

or like this below ↓ Convert.ToDecimal(5).ToString(“00000”)
image

@Russia_N_Novgorod Please use preserve format option checked while read range. It will definitely resolve your issue.

I did about the same. But the number of characters in the original is not known in advance. It turns out that you need to first find the number of characters and then substitute it into the expression.

Can you provide a screenshot?

@Russia_N_Novgorod image

Thank you very much! I’ll take a look and unsubscribe.

Hi @Russia_N_Novgorod Have you tried this method yet? ----> string.concat(“'”, yourVariableDatatable) with [" ’ "] the first part that I have written, force excel to read the number as you want

Yes, this is the solution! Thank you.

The previous solution to the problem is easier in my opinion. But thank you, I will take note of your decision!

Yes, this is the solution! Thank you.

@Russia_N_Novgorod my pleasure :crazy_face:. I think you have marked your reply as solution :wink:

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