How can i Move the Regex data into Excel file plz ?
Give some more explanation please.
Inside “Insert Column” write “item” in place of “Tel”
This will solve the problem
I used regex to extract information from PDF file, after that i want to write the information in a Excel File
it doesnt work, i think there is a problem with the datatable
Did i need to convert regex on datatable ?
@Soudios Don’t use ‘insert column’ - you should use write cell activity instead. Your regex will only be a single match. You’ll have to use an index or other counter variable to make sure that each match is put into a new row/column in your insert cell activity
Also, the matches activity returns an ienumerable(of match). If you want to get the string from the regex match, then you need to access the .Value property. So you want to switch it from item.tostring → item.Value instead. The .Value property is already a string so there’s no need to append the .ToString on at the end
@Dan_K i used write cell but it doesnt work
What does the error say when you hover over that blue exclamation point? Make sure that the TypeArgument property in your for each statement is set to System.Text.RegularExpressions.Match
Also, you have an entire range in there, but item.value will only take up a single cell.
No more error message but you are right i need someting to write all the information in all the cell that it needs
You’ll have to use an index or other counter variable to make sure that each match is put into a new row/column in your insert cell activity.
So if you want it to start at cell G2, then you can output the ForEach index (i’ll call it CurrentRow) and add +2. That way it will always input into the correct row.
One other important thing: I would move the excel application scope OUTSIDE the for each window. Otherwise it will constantly be opening/closing excel which will give errors as the robot will move faster than the excel process can be started/stopped.
So your for each will be as follows.
Excel Application Scope
For each item in Tel
Write Cell: SheetName="Feul1"; Range="G" + CurrentRow + 2; Value=item.value
I don’t know what is the problem, it is not easier to use write range ?
Sorry I forgot to add the .tostring portion. Change it to
"G" + (CurrentRow + 2).ToString
You are writing a single cell each iteration of your for each loop. You can’t use write range, as that is for datatables only (you are using a regex.match variable, not a datatable).
If you do prefer to use write range because you ahve to write many rows, then you can still do that. Just alter your logic so it first writes each match.value into a new datarow. Then outside of that for each loop, you would write your datatable to the excel file at cell G2. So it’d look like this:
Build Datatable: save as dt1, only 1 single column of type string For each item in Tel Add datarow: table=dt1; value=item.value End for each Excel Application Scope Write Range: Range="G2"
So now i need to duplicate this sequence to every regex i want ? or i can create a database with all the regex and then i write it in Excel ?
No need to duplicate. Yes, the datatable is created once, then added to with each regex match found in your ‘matches’ activity, then written to excel all at once. Just make sure to do it in the order I have written in my post above - all of that comes directly after your ‘matches’ activity
How can i add every thing in the same place ?
I used WriteCell, i think is easier
Are you using a separate regex to read the emails? If so, then you will have to repeat it. It should be an exact repeat of the telephone sequence, but just change the regex to look for email instead, and change the write cell column from G to whichever column should contain email.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.