Why doesn't WordWriter Repeat-block in an IF expression display a document successfully?

While working on the word template, it was necessary to place the repeat blocks in the IF field , similar to the following:

Sample WordTemplate code using .DOC / .DOCX:

{ IF {MERGEFIELD DataSource1.FieldName}="123456" "IF SECTION Then a repeat block here using a table row that is bookmarked: ------------------------------------------------------------ | «Datasource1.IdColHeader» | «Datasource1.NameColHeader» | ------------------------------------------------------------ |«RepeatingDatasource2.Id» | «RepeatingDatasource2.Name» | ------------------------------------------------------------ " "Else Section Second set of repeat block with different datasource ------------------------------------------------------- | Id | Name | ------------------------------------------------------- |«RepeatingDatasource3.Id»|«RepeatingDatasource3.Name»| ------------------------------------------------------- "} 

Sample C # code using WordWriter WordTemplate:

 private static void ProcessWordTemplate(WordTemplate docTemp) { try { docTemp.Process(); } catch (Exception ex) { throw new ApplicationException(ex.Message); } } 

For WordTemplate DOCX, an error occurs when docTemp.Process() . I get the following exception:

Exception Type: System.Application
Exception message: WordWriter error: bookmarks cannot be overwritten

For the WordTemplate DOC, documents were processed, but only one line is displayed in the repeat block, even if the actual result is more than 1.

But, if everything is the other way around, the IF field in the repeat block , the IF field and the repeat block were successfully evaluated. The received document shows all records.

Please note that I am using OfficeWriter WordWriter version 9.

+5
source share

All Articles