Conditional background colors for rows, foreach error

I have upload the code of our project and also the template, output and desired output.
The template is SecuritiesBySuperSectorBySubSector.doc.

Is it possible to conditionally apply different background colors to the rows? I have tried the backColor tag on numbered list and it worked. But does not seem to be working for table rows. Please see the current output in SecuritiesBySuperSectorBySubSector_Output.doc And our desired output in SecuritiesBySuperSectorBySubSector_Output_Desired.doc.

Another question, when I add a new blank column at the beginning of the table, the report engine throws this error.
foreach’ is not well-formed. Cannot copy or remove document contents between different stories or cells of different tables. Please let me know what I am doing wrong.

Hi Roel,

Thanks for your inquiry. Unfortunately, we have not found any documents with this post.

If you are using LINQ Reporting engine, you can achieve your requirement using conditional blocks. Please refer to the following articles:
Working with Common Conditional Blocks
Multicolored Numbered List Template

If you are using mail merge engine, please refer to the following article:
How to Apply Custom Formatting during Mail Merge

If you still face problem, please share your input and expected output documents here for our reference. We will then provide you more information about your query.

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

Sample.zip (36.2 KB)
My apologies. It’s attached now. Source code, input template, created output, desired output.

Hi Roel,

Thanks for sharing the detail. In your template document, some formatting is applied to text. We cleared the text formatting using MS Word and apply same font style in your template document. The shared code example generates the desired output. Please get the modified template document and output document from following link.
https://www.dropbox.com/s/zk8abfmwtqng650/Linq%20Template_322.zip?dl=0

In case you are using older version of Aspose.Words, we suggest you please use latest version of Aspose.Words for .NET 17.6.

Moreover, we suggest you please read following article:
Working with Table-Row Conditional Blocks

Hi,
This is Rajesh and I work with Roel. I looked at the template and the output. Could you please explain how exactly did you clear the formatting? These templates would like be created by an end user. So, there are chances that they might try to format texts using MS Word. And also, we still don’t see the answer to the other question which is, when added one blank column at the beginning of this table, it started throwing this error even with the template you sent.

foreach’ is not well-formed. Cannot copy or remove document contents between different stories or cells of different tables
Is there any reason we cannot do this?

Hi Rajesh,

Thanks for your inquiry.

Please open the document in MS Word and select the table. Under Home tab, click “Clear All Formatting” in Font group. Or click “Clear Formatting” from style group.

I requested for input document and code example in my previous post. Please check my previous post. Thanks for your cooperation.

A post was split to a new topic: Font formatting issue in Word documents