Where is that code executed? As you probably know, every time the report is previewed, paged or exported through the viewer it is processed and rendered from scratch. Check whether upon export your code is executed again and whether it goes in the foreach loops as expected.
If you are unable to pinpoint the issue, please open a support ticket and attach a runnable sample that exhibits the problem and we would advise you accordingly.
the Telerik team