Hi team,
The number 0 keeps getting truncated when trying to work with the number starting with 0. I tried to use text format in the input excel file, but the issue still persisted.
Can anyone help with this?
Here is the screenshot for your visibility.
1 Like
@Sisay_Dinku Try with
inputstring.TrimStart(‘0’) -string
Number-Inside for each row in datatable activity, Assign Row(0)=Cint(Row(0).ToString)
1 Like
Sanjit_Pal
(Sanjit Pal)
November 29, 2022, 3:20am
3
Hey @Sisay_Dinku ,
While reading the data from excel using read range activity check the Preserve Format property and try.
Thanks,
Sanjit
1 Like
@sangeethaneelavannan1 thank you. I forgot to mention but not all numbers begin with zero (0), some are just natural numbers like 92145 (five digit)
1 Like
Yoichi
(Yoichi)
November 29, 2022, 3:22am
5
Hi,
Can you try to use Workbook-WriteRange activity?
Regards,
1 Like
@Yoichi
I use modern design
I write from data table to excel (using Write Data table to excel activity). Is there anything I can do while reading before writing?
1 Like
@Sisay_Dinku
Check if row (0). first == 0 then do the truncate otherwise leave it as it is.
1 Like
Yoichi
(Yoichi)
November 29, 2022, 3:40am
8
Hi,
Sisay_Dinku:
modern design
How about to use FormatCell in advance, as the following? Please also check the following sample.
Sample20221129-3.zip (11.2 KB)
Regards,
2 Likes
@Yoichi
It looks like it did not work. If I may ask, why do we use the second sheet (sheet2)? Is there any way that I can use on the same sheet1
1 Like
@Sisay_Dinku Did you try this
Check if row (0). first == 0 then do the truncate otherwise leave it as it is.
1 Like
@sangeethaneelavannan1 I do not want to do any truncation. I just wanted the input 5 digit zip code to be as is when taken to output. The only issue I have is when there is 0 at the beginning, it gets truncated and only four digits loaded.
1 Like
@Sisay_Dinku
how about this?
1 Like
@sangeethaneelavannan1 I tried that as I was suggested by @Yoichi . However, I could not see any changes.
1 Like
Anil_G
(Anil Gorthi)
November 29, 2022, 7:25am
14
Hi @Sisay_Dinku
Just include a single apostrophe (‘) before the number value and then write the cell. Then it wont truncate zero . Excel will assume the cell as text and will not change the format
Cheers
1 Like
Hi
But the (') is going to be loaded into the output file in addition to the Zero (0). I need clean number starting with 0
Anil_G
(Anil Gorthi)
November 29, 2022, 3:10pm
16
Hi @Sisay_Dinku
Can you check that because generally when we load data to system with this it would not create any issue as excel will ignore it
Alternately you can try giving the value as formula like this =TEXT(“02345”,“00000”)
cheers
Hi
Here is the screenshot. FYI, the final output is in CSV format. Thanks
I did but it throws an error. If you do not mind, can you show me the full assign using an example? Thanks!
Anil_G
(Anil Gorthi)
November 29, 2022, 5:57pm
20
Hi @Sisay_Dinku
This is not in assign.
This the formula for excel.
You have to use it in write cell activity to set the formula in excel
UiPath.Excel.Activities.ExcelWriteCell Writes a value or formula into a specified spreadsheet cell or a range. If the sheet does not exist, a new one is created with the name specified in the SheetName property. If a value exists, it is overwritten....
Cheers