[OfficeUtils] Upgrade OfficeUtils from v3 to v5: error generating words
Forge component by Bruno Gonçalves
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

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

Hello Elena,

I'm experiencing a similar issue. As far as I can see, I believe that we we are filling the placeholders correctly.

Can you help me translate the error message, please?

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, String url)
at OutSystems.NssOfficeUtils.CssOfficeUtils.ProcessParagraph(XWPFParagraph paragraph, RCWordFileRecord ssWordFile, List`1 ParagraphToRemove, Object context)
at OutSystems.NssOfficeUtils.CssOfficeUtils.ProcessTable(XWPFTable table, RCWordFileRecord ssWordFile, List`1 TableToRemove, Object context)
at OutSystems.NssOfficeUtils.CssOfficeUtils.ProcessTables(IEnumerator tablesEnumerator, RCWordFileRecord ssWordFile, List`1 TableToRemove, Object context)
at OutSystems.NssOfficeUtils.CssOfficeUtils.MssGenerateWordFile(RCWordFileRecord ssWordFile, Byte[]& ssWordBinary)
   at ssOfficeUtils.RssExtensionOfficeUtils.MssGenerateWordFile(HeContext heContext, IRecord inParamWordFile, Byte[]& outParamWordBinary)

Hi Ana,

The error has to do with my logic of the replacement of the text, what exactly causes it just by looking at the error i can't say. If you could send me your template i could try to run it locally and see why the error has been raised. 


Best regards,

Elena

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.