Hi all, I have an excel file containing values in date format, which however are not recognized as dates until after I have clicked on the cell containing them and pressed enter.
Does anyone have a better solution instead of clicking and entering, because I have too many cells (over 50000) to click and the bot takes too long to do it?
Hi @Simone_Trenta
In UiPath, you can use the Get Text
activity to extract the text from a date cell and then use a regex or the DateTime.Parse
method to parse the text and recognize it as a date.
Here is an example of how you could extract and parse the text from a date cell using the Get Text
and DateTime.Parse
activities:
- Use the
Get Text
activity to extract the text from the date cell. - Use the
DateTime.Parse
method to parse the text and recognize it as a date. You can do this by using anAssign
activity to assign the result of theDateTime.Parse
method to a variable.
For example, the following code would extract the text from a date cell and parse it as a date, storing the result in a variable called parsedDate
:
Text = Get Text(dateCell)
parsedDate = DateTime.Parse(Text)
Alternatively, you can use a regex to recognize the date in the text. To do this, you can use the Regex.Match
method to search for a pattern that matches the format of the date in the text. If a match is found, you can use the Match.Value
property to extract the date from the text.
Here is an example of how you could use a regex to recognize a date in the text extracted from a date cell:
Text = Get Text(dateCell)
regex = "\d{2}-\d{2}-\d{4}"
match = Regex.Match(Text, regex)
If match.Success Then
parsedDate = match.Value
End If
Cheers.
I have already the DataTable with recognized date format cells.
In my excel file i have columns in date format, but when the bot write the datatable using write range in excel scope, the values in data format isn’t recognized as date.
if you select the column and do a format change manually, is it working? ( Home->format->Format cells)
If yes, you can use Format cell activity to change the format of the values.
Thanks
Not, it works only if i click on cell and then send enter (with the cell format in date)
will that be possible to share a dummy table with the specified formated data?
Thanks
Yeah,
DummyFile_Table.xls (1.7 MB)
the first 18750 rows is correctly formatted because i clicked and send enter in cycle but it is too long to do for all…
Thanks