SharpDocx icon indicating copy to clipboard operation
SharpDocx copied to clipboard

Problem in For cyclus

Open LadislavSopko opened this issue 5 years ago • 0 comments

Hello, In first Nice project. I did a try to use it in my case. I need Multilanguage document generator. I decide tu use FieldCode in this manner:

<% for(int i = 0; i < 10; ++i){ %>
{ INCLUDETEXT "{FILENAME \p}/../Texts<%=Model.Lang%>.docx" Main_001 }
<% } %>

INCLUDETEXT will load part of other document into current. I want to change include file name depending on current language. I have parallel files with bookmarked text blocks, and word will replace them after. I saw that your code did not handle FieldCode out of the box, so I did some fix to make it work. But there is a problem with this. SharpXdoc will replace only the first iteration with correct language string, resting 9 lines will come without Lang. it produces this :

{ INCLUDETEXT "{FILENAME \p}/../TextsIT.docx" Main_001 }
{ INCLUDETEXT "{FILENAME \p}/../Texts.docx" Main_001 }
{ INCLUDETEXT "{FILENAME \p}/../Texts.docx" Main_001 }
{ INCLUDETEXT "{FILENAME \p}/../Texts.docx" Main_001 }
{ INCLUDETEXT "{FILENAME \p}/../Texts.docx" Main_001 }
...

I did a try to debug it, but I did not figure out while it not work. I make branch: "feature/laco/Add_FuncCode" in my fork with problem project "Test" You can check it here: https://github.com/LadislavSopko/SharpDocx/tree/feature/laco/Add_FuncCode

Feel free take my fixes for FieldCode if you like it.

Regards Ladislav

LadislavSopko avatar Mar 15 '20 14:03 LadislavSopko