10
Views
3
Comments
[OfficeUtils] Upgrade OfficeUtils from v3 to v5: error generating words
Forge component by Bruno Gonçalves
30
Published on 18 Dec 2020
Application Type
Traditional Web
Platform Version
11.9.1 (Build 20359)

Hi,

we have upgraded OfficeUtils from v3 to v5.

During the tests we are the following the error above.

can help us how can we overcome this error

Sequence contains no elements
at System.Linq.Enumerable.Aggregate[TSource](IEnumerable`1 source, Func`3 func)
at OutSystems.NssOfficeUtils.CssOfficeUtils.ReplaceText(String pattern, XWPFParagraph p, String replaceText, Int32 matchIndex)
at OutSystems.NssOfficeUtils.CssOfficeUtils.ProcessWordPicture(String placeholder, RCWordPictureRecord ssWordFile, XWPFParagraph paragraph, Object context, Int32 matchIndex)
at OutSystems.NssOfficeUtils.CssOfficeUtils.ProcessParagraph(XWPFParagraph paragraph, RCWordFileRecord ssWordFile, List`1 ParagraphToRemove, Object context)
at OutSystems.NssOfficeUtils.CssOfficeUtils.ProcessParagraphs(IEnumerator paragraphsEnumerator, RCWordFileRecord ssWordFile, List`1 ParagraphToRemove, Object context)
at OutSystems.NssOfficeUtils.CssOfficeUtils.MssGenerateWordFile(RCWordFileRecord ssWordFile, Byte[]& ssWordBinary)
at ssOfficeUtils.RssExtensionOfficeUtils.MssGenerateWordFile(HeContext heContext, IRecord inParamWordFile, Byte[]& outParamWordBinary)


Regards

Miguel anselmo

Hi Miguel,

Could you send me your template and a screenshot which parameters you are using on "Word_Export_SetPicture"

like this: 

seems that something goes wrong with removing the placeholder in this scenario.


Best regards,

Elena

Rank: #2120

Hi Elena,

i send the the screenshot requested.

On the private conversation i will send the templates.

Thanks.

Best regards

Miguel Anselmo


Untitled.png

Hi Miguel,

I have checked your template. 

In the version 4 i have started to use a different logic to find matches of the text inside the document. One part of this logic is c# Regex.Match() function.

The issue that you are seeing has to do with the way you put placeholders in the format "[TECHNICIAN_SIGNATURE]".  What is happening then is that it is misunderstood due to the regular expression parser which knows the following: [ ] the opening and closing square brackets define a character class to match a single character. 

So if i have Regex.Match("Text", "[TECHNICIAN_SIGNATURE]"); it would resolve with matching found.

I would recommend you to replace the placeholders with [] to something like "#TECHNICIAN_SIGNATURE#"

And i will think how to improve this functionality in the future.

Best regards,

Elena