Free Support Forum - aspose.com

Dynamic Documents Template Expressions

I was taking a look at the Linq reporting engine and found an interesting feature of inserting documents dynamically.
When I tried it out, I could see that the template expressions in the embedded document is not evaluated by the engine. Is it something that I am doing wrong, or is there no such capability of resolving template expressions inside the embedded document.

Thanks in advance

@Tritty,

Thanks for your inquiry. Please ZIP and attach your input, embedded document, and expected output. We will then provide you more information about your query.

Hi @tahir.manzoor,

Think I have the same issue or wrong setup/understanding.

I have two documents HelloWorld.docx that takes a data source and then dynamically loads another document Inner.docx. The data context works in the HelloWorld document and I can see the values but in the sub document I still see the tags.

  • HelloWorld.docx -
    <<[ Name ]>>
    <<doc [“Inner.docx”]>>

  • Inner.docx -
    Sub Document
    <<[ Name ]>>
    <<[ Message ]>>

  • Output -
    LINQ Reporting Engine
    Sub Document
    <<[ Name ]>>
    <<[ Message ]>>

If this is the wrong way just let me know.
Looked around on the docs and forum but could not find any mention of anything special needed so any help would be appreciated.

Thanks

Attached is a zip of my test project

ConsoleApp1.zip (169.2 KB)

@ekvm.de,

Thanks for your inquiry. We have logged this feature request as WORDSNET-16817 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

@ekvm.de,

Thanks for your patience. You can use ReportingEngine.KnownTypes in conjunction with a doc tag to achieve your requirement as shown in the following code snippet. We have attached the modified input document with this post. HelloWorld Modified.zip (9.6 KB)

Hope this helps you.

Sender sender = new Sender { Name = "LINQ Reporting Engine", Message = "Hello World" };
Document doc = DocHelper.BuildDoc("HelloWorld Modified.docx", sender, "s");
 
doc.Save(MyDir + "18.5.docx");

public class Sender
{
    public string Name { get; set; }
    public string Message { get; set; }
}

public static class DocHelper
{
    public static Document BuildDoc(string fileName, object dataSource, string dataSourceName)
    {
        string path = Path.Combine(RootDir, fileName);
        Document doc = new Document(path);

        ReportingEngine engine = new ReportingEngine();
        engine.KnownTypes.Add(typeof(DocHelper)); // This allows to use members of this class while building a report.

        engine.BuildReport(doc, dataSource, dataSourceName);
        return doc;
    }

    private const string RootDir = "c:\\temp\\";
}

The issues you have found earlier (filed as WORDSNET-16817) have been fixed in this Aspose.Words for .NET 18.8 update and this Aspose.Words for Java 18.8 update.