I am doing a Excel Read Range, later I use for each row data table and get row item.
The objective is to make the column format number, and it is required to use the following rules
those that have more than 10 characters, take the 10 characters from right to left
If the field has less than 10 characters, they are removed
To count the number of characters I am using
vph.Length.ToString
To identify if the field has more than 10 characters I am using an if vCountpn>=“10”
To extract the 10 characters from right to left I use the following vCountpn.Substring(vCountpn.Length -10), in this part is where I get the error StartIndex cannot be less than zero. (Parameter ‘startIndex’)
After that, overwrite the column that shows the data of the fields, with the 10 characters
I appreciate you can help me
Hello
Using the message box with
assign
vCountpn = vph.Length.ToString , has a value of 16 characters
when using the substring vCountpn.Substring(vCountpn.Length -10), I get the error.
I have something wrong in the substring
StartIndex cannot be less than zero. (Parameter ‘startIndex’)
I have other question . I have a column with the information dd/MM/yyyy hh:mm:ss. I want to make parser to the dd/MM/yyyy
I have read range excel of the column date, the save to is vRange
I have for each row in data table , with for each CurrentRow
I have get row item with value vfecha
I have Assign DateTime.ParseExact(CurrentRow(“created_time”).ToString,“dd/MM/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”) and the error is String ‘1/6/2023’ was not recognized as a valid DateTime
Use the “Read Range” activity to read the Excel file and store the data in a DataTable variable, let’s call it dataTable.
Add a “For Each Row” activity to loop through each row in the dataTable.
Within the loop, use an “Assign” activity to get the value of the number column and store it in a variable, let’s call it vph.
Add an “If” activity with the condition vph.Length >= 10 to check if the value has more than 10 characters.
Inside the “Then” section of the “If” activity, use an “Assign” activity to extract the rightmost 10 characters from the value and store it back in vph. You can use vph = vph.Substring(vph.Length - 10).
Outside the “If” activity, use another “Assign” activity to update the value of the number column in the current row with vph. You can use CurrentRow("NumberColumn") = vph.
Finally, outside the loop, use the “Write Range” activity to write the modified dataTable back to the Excel file.