Looping values from PDF

Hi,

I’ve trouble outputting order data to excel. I’ve regexed bolded values and currently order numbers go to their separate Excel columns as i want. First order to B1> next order to C1 etc.
Under these order numbers i have BIR numbers outputting correctly. First one B2, second C2 etc. But then how can i get Kund Material nr and their amount (1-54st) listed under the same Order column in excel? Difference is that these might have multiple values in same order.
Under we have output from a single PDF invoice.

Order: 123456 skapad 2019.10.28 Ert order nr.: 123456
Leveransnr.: 12345678 BIR: 12345
Kund-material nr.: 123456789
11 st 1.234,00 SEK
Kund-material nr.: 987654321
40 st 1.234,00 SEK
Kund-material nr.: 123459876
54 st 1.234,00 SEK

Order: 654321 skapad 2019.11.20 Ert order nr.: 123456
Leveransnr.: 12345678 BIR: 54321
Kund-material nr.: 123567891
1 st 1.234,00 SEK

Order: 987654 skapad 2019.11.20 Ert order nr.: 123456
Leveransnr.: 12345678 BIR: 54321
Kund-material nr.: 123567891
1 st 1.234,00 SEK

Order: 789654 skapad 2019.11.20 Ert order nr.: 123456
Leveransnr.: 12345678 BIR: 54321
Kund-material nr.: 123567891
1 st 1.234,00 SEK
Kund-material nr.: 987654321
40 st 1.234,00 SEK
Kund-material nr.: 123459876
54 st 1.234,00 SEK

Do you want all the highlighted values?
You can write Regex for Kund-material nr.: and then loop over the RegexResults variable

1 Like

Hi,

Yes i want highlighted values from each order. Highlighting is now only in first one…

I’ve already Regexed all the needed values. Only issue is how to get them nicely organized to Excel under Order Columns. Too many loops for my brain! :smiley:

Try splitting with \n\n two new lines, then all the orders will be grouped…Use for each to iterate each order…! @Mikko_S

Thanks!

I’ve done the splitting of Orders with PdfInvoice.Split({“Order:”},StringSplitOptions.None) and it is working well. Like mentioned i’m already getting Order No and BIR no from the loop. But when it comes to rest of the values i’ve trouble getting them sorted correctly to Excel columns.

Ok my problem description was not maybe best one but i managed to tackle this by switching from “for” to “while” loop +counter when matching values. This way i could tag all the details from single order field with regex and throw this sequence next to for loop to make it purr… :slight_smile:

1 Like

can you please provide xaml? i have similar problem

Unfortunately i cannot. There’s client information in xaml- files. But in pseudocode. First we read PDF, then we go to while loop where counter is set according to amount of my orders. In a loop we have all the needed Regex- matches activities. After this we go each Regex through in a for- loop to print values to Excel. My For- loops are also inside the first while. I know, not the most elegant design, but works! :slight_smile:

thanks, will be helpful if you can share while loop and regex code…

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